This repository was archived by the owner on Jun 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +107
-18
lines changed Expand file tree Collapse file tree 5 files changed +107
-18
lines changed Original file line number Diff line number Diff line change 11version : 2
22
33jobs :
4- php72 :
4+
5+ php74 :
56 docker :
6- - image : circleci/php:7.2 -cli
7+ - image : circleci/php:7.4 -cli
78
89 working_directory : ~/project
910 steps :
1011 - checkout
1112 - run :
1213 name : Run tests / Symfony 4^3
1314 command : |
14- composer update -n --prefer-dist --prefer-stable --no-suggest
15+ composer update -n --prefer-dist --prefer-stable
1516 php vendor/bin/phpunit
1617
1718 - run :
1819 name : Run tests / Symfony 5^0
1920 command : |
20- composer update -n --prefer-dist --no-suggest
21+ composer update -n --prefer-dist
2122 php vendor/bin/phpunit
2223
23- php74 :
24+ php80 :
2425 docker :
25- - image : circleci/php:7.4 -cli
26+ - image : circleci/php:8.0 -cli
2627
2728 working_directory : ~/project
2829 steps :
2930 - checkout
3031 - run :
31- name : Run tests / Symfony 4^3
32- command : |
33- composer update -n --prefer-dist --prefer-stable --no-suggest
34- php vendor/bin/phpunit
35-
36- - run :
37- name : Run tests / Symfony 5^0
32+ name : Run tests
3833 command : |
39- composer update -n --prefer-dist --no-suggest
34+ composer update -n --prefer-dist
4035 php vendor/bin/phpunit
4136
4237workflows :
4338 version : 2
4439 test :
4540 jobs :
46- - php72
47- - php74
41+ - php74
42+ - php80
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Apisearch PHP Client.
5+ *
6+ * For the full copyright and license information, please view the LICENSE
7+ * file that was distributed with this source code.
8+ *
9+ * Feel free to edit as you please, and have fun.
10+ *
11+ * @author Marc Morera <yuhu@mmoreram.com>
12+ */
13+
14+ declare (strict_types=1 );
15+
16+ namespace Apisearch \Exception ;
17+
18+ /**
19+ * Class EmptyBodyException.
20+ */
21+ class PayloadTooLargeException extends TransportableException
22+ {
23+ /**
24+ * @return int
25+ */
26+ public static function getTransportableHTTPError (): int
27+ {
28+ return 413 ;
29+ }
30+
31+ /**
32+ * @return self
33+ */
34+ public static function create (): self
35+ {
36+ return new static ('You sent us a too large payload. Please, consider reducing this size. ' );
37+ }
38+ }
Original file line number Diff line number Diff line change 1919use Apisearch \Exception \ForbiddenException ;
2020use Apisearch \Exception \InvalidFormatException ;
2121use Apisearch \Exception \InvalidTokenException ;
22+ use Apisearch \Exception \PayloadTooLargeException ;
2223use Apisearch \Exception \ResourceExistsException ;
2324use Apisearch \Exception \ResourceNotAvailableException ;
2425use Apisearch \Exception \TooManyRequestsException ;
@@ -60,6 +61,8 @@ protected static function throwTransportableExceptionIfNeeded(
6061 throw new ForbiddenException ($ response ['body ' ]['message ' ]);
6162 case TooManyRequestsException::getTransportableHTTPError ():
6263 throw new TooManyRequestsException ($ response ['body ' ]['message ' ]);
64+ case PayloadTooLargeException::getTransportableHTTPError ():
65+ throw new PayloadTooLargeException ($ response ['body ' ]['message ' ]);
6366 case ConnectionException::getTransportableHTTPError ():
6467 throw new ConnectionException ('Apisearch returned an internal error code [500] - ' .$ response ['body ' ]['message ' ]);
6568 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Apisearch PHP Client.
5+ *
6+ * For the full copyright and license information, please view the LICENSE
7+ * file that was distributed with this source code.
8+ *
9+ * Feel free to edit as you please, and have fun.
10+ *
11+ * @author Marc Morera <yuhu@mmoreram.com>
12+ */
13+
14+ declare (strict_types=1 );
15+
16+ namespace Apisearch \Tests \Exception ;
17+
18+ use Apisearch \Exception \PayloadTooLargeException ;
19+ use Apisearch \Exception \TransportableException ;
20+ use PHPUnit \Framework \TestCase ;
21+
22+ /**
23+ * Class PayloadTooLargeExceptionTest.
24+ */
25+ class PayloadTooLargeExceptionTest extends TestCase
26+ {
27+ /**
28+ * Assert that returns proper transportable error.
29+ */
30+ public function testTransportableErrorCode ()
31+ {
32+ $ this ->assertInstanceOf (
33+ TransportableException::class,
34+ new PayloadTooLargeException ()
35+ );
36+
37+ $ this ->assertEquals (
38+ 413 ,
39+ PayloadTooLargeException::getTransportableHTTPError ()
40+ );
41+ }
42+
43+ /**
44+ * Assert that extends an exception.
45+ */
46+ public function testExtendsException ()
47+ {
48+ $ this ->assertInstanceOf (
49+ \Exception::class,
50+ new PayloadTooLargeException ()
51+ );
52+ }
53+ }
Original file line number Diff line number Diff line change 1010 }
1111 ],
1212 "require" : {
13- "php" : " >=7.2 " ,
13+ "php" : " ^7.4 | ^8.0 " ,
1414 "ext-curl" : " *" ,
1515 "symfony/event-dispatcher" : " ^3.4 || ^4.0 || ^5.0" ,
1616 "symfony/yaml" : " ^3.4 || ^4.0 || ^5.0" ,
1717 "nesbot/carbon" : " ^1.22 || ^2.0"
1818 },
1919 "require-dev" : {
20- "phpunit/phpunit" : " 7.5.17 "
20+ "phpunit/phpunit" : " ^9 "
2121 },
2222 "autoload" : {
2323 "psr-4" : {
You can’t perform that action at this time.
0 commit comments