diff --git a/composer.json b/composer.json index b9b32cc..f544fed 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ }, "autoload": { - "files": ["lib/Tinify.php", "lib/Tinify/Exception.php"], - "psr-4": {"Tinify\\": "lib/Tinify/"} + "psr-4": {"Tinify\\": "lib/Tinify/"}, + "files": ["lib/functions.php"] } } diff --git a/lib/Tinify/AccountException.php b/lib/Tinify/AccountException.php new file mode 100644 index 0000000..7d4ec15 --- /dev/null +++ b/lib/Tinify/AccountException.php @@ -0,0 +1,5 @@ +request("post", "/shrink"); - } catch (AccountException $err) { - if ($err->status == 429) return true; - throw $err; - } catch (ClientException $err) { - return true; - } -} diff --git a/lib/functions.php b/lib/functions.php new file mode 100644 index 0000000..7db27ba --- /dev/null +++ b/lib/functions.php @@ -0,0 +1,48 @@ +request("post", "/shrink"); + } catch (AccountException $err) { + if ($err->status == 429) return true; + throw $err; + } catch (ClientException $err) { + return true; + } +} diff --git a/test/base/test_case_1.php b/test/base/test_case_1.php index 3a2082b..3755d57 100644 --- a/test/base/test_case_1.php +++ b/test/base/test_case_1.php @@ -3,7 +3,7 @@ abstract class TestCase_1 extends \PHPUnit\Framework\TestCase { protected function setUp() { Tinify\CurlMock::reset(); Tinify\setKey(NULL); - TInify\setProxy(NULL); + Tinify\setProxy(NULL); } protected function tearDown() { diff --git a/test/base/test_case_2.php b/test/base/test_case_2.php index b65bf1b..7c69890 100644 --- a/test/base/test_case_2.php +++ b/test/base/test_case_2.php @@ -3,7 +3,7 @@ abstract class TestCase_2 extends \PHPUnit\Framework\TestCase { protected function setUp(): void { Tinify\CurlMock::reset(); Tinify\setKey(NULL); - TInify\setProxy(NULL); + Tinify\setProxy(NULL); } protected function tearDown(): void { diff --git a/test/bootstrap.php b/test/bootstrap.php index 4877c42..2653d50 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,7 +1,7 @@