Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| BadRequestException | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| getStatusCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getTitle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Domain\Exception; |
| 6 | |
| 7 | use InvalidArgumentException; |
| 8 | |
| 9 | /** |
| 10 | * Thrown when the request structure is invalid — missing required fields, |
| 11 | * wrong types, malformed JSON, or otherwise unparseable input. |
| 12 | * |
| 13 | * Use this for *structural* problems with the request only. For value-level |
| 14 | * validation errors (e.g. "amount must be greater than zero"), use |
| 15 | * {@see ValidationException} instead. For state conflicts (e.g. "loan is |
| 16 | * already approved"), use {@see ConflictException}. |
| 17 | * |
| 18 | * Maps to HTTP 400 Bad Request. |
| 19 | */ |
| 20 | final class BadRequestException extends InvalidArgumentException implements HttpStatusException |
| 21 | { |
| 22 | public function getStatusCode(): int |
| 23 | { |
| 24 | return 400; |
| 25 | } |
| 26 | |
| 27 | public function getTitle(): string |
| 28 | { |
| 29 | return 'Bad Request'; |
| 30 | } |
| 31 | } |