Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
20 | public function __construct(Throwable $e) |
||
21 | { |
||
22 | 6 | /** @var array<int, string> $text */ |
|
23 | $text = (new StatusCode())->statusText; |
||
24 | 6 | if ($e instanceof BadRequestException) { |
|
25 | 6 | $this->code = $e->getCode(); |
|
26 | 2 | $this->text = $text[$this->code] ?? ''; |
|
27 | 2 | ||
28 | return; |
||
29 | 2 | } |
|
30 | |||
31 | 4 | if ($e instanceof RuntimeException) { |
|
32 | 1 | $this->code = 503; |
|
33 | 1 | $this->text = $text[$this->code]; |
|
34 | |||
35 | 1 | return; |
|
36 | } |
||
37 | 3 | ||
38 | 3 | $this->code = 500; |
|
39 | 3 | $this->text = $text[$this->code]; |
|
40 | } |
||
42 |