Total Complexity | 4 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | abstract class AbstractException extends RuntimeException implements HttpExceptionInterface |
||
11 | { |
||
12 | protected int $statusCode; |
||
13 | |||
14 | 160 | public function __construct( |
|
15 | string $message = '', |
||
16 | Throwable $previous = null, |
||
17 | protected array $headers = [], |
||
18 | int $code = 0 |
||
19 | ) { |
||
20 | 160 | if ('' === $message) { |
|
21 | 80 | $statusCode = $this->getStatusCode(); |
|
22 | 80 | $entity = (new HttpStatus($statusCode))->get(); |
|
23 | 80 | $message = sprintf('%d %s', $entity->statusCode, $entity->name); |
|
24 | } |
||
25 | |||
26 | 160 | parent::__construct($message, $code, $previous); |
|
27 | } |
||
28 | |||
29 | 160 | public function getStatusCode(): int |
|
30 | { |
||
31 | 160 | return $this->statusCode; |
|
32 | } |
||
33 | |||
34 | 80 | public function getHeaders(): array |
|
37 | } |
||
38 | } |
||
39 |