Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| NotFoundException | |
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 DomainException; |
| 8 | |
| 9 | /** |
| 10 | * Thrown when a requested resource does not exist. |
| 11 | * |
| 12 | * Examples: |
| 13 | * - "Loan 42 not found" |
| 14 | * - "No account found for this investor" |
| 15 | * - "Document not found" |
| 16 | * |
| 17 | * If the resource exists but the user is not allowed to see it, throw |
| 18 | * {@see ForbiddenException} (or {@see AuthenticationException} if not |
| 19 | * logged in) instead — leaking the existence of a resource the user can't |
| 20 | * access can be a security issue. |
| 21 | * |
| 22 | * Maps to HTTP 404 Not Found. |
| 23 | */ |
| 24 | final class NotFoundException extends DomainException implements HttpStatusException |
| 25 | { |
| 26 | public function getStatusCode(): int |
| 27 | { |
| 28 | return 404; |
| 29 | } |
| 30 | |
| 31 | public function getTitle(): string |
| 32 | { |
| 33 | return 'Not Found'; |
| 34 | } |
| 35 | } |