Total Complexity | 7 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class HttpException extends Exception |
||
12 | { |
||
13 | /** |
||
14 | * @var int |
||
15 | */ |
||
16 | private int $statusCode; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private string $reasonPhrase; |
||
22 | |||
23 | /** |
||
24 | * @param int $statusCode |
||
25 | * @param string|null $reasonPhrase |
||
26 | * @param Throwable|null $previous |
||
27 | */ |
||
28 | 39 | public function __construct(int $statusCode, ?string $reasonPhrase = null, ?Throwable $previous = null) |
|
29 | { |
||
30 | 39 | $reasonPhrase ??= ''; |
|
31 | |||
32 | 39 | if ($reasonPhrase === '' && isset(ErrorResponseGeneratorInterface::ERROR_PHRASES[$statusCode])) { |
|
33 | 28 | $reasonPhrase = ErrorResponseGeneratorInterface::ERROR_PHRASES[$statusCode]; |
|
34 | } |
||
35 | |||
36 | 39 | $this->statusCode = $statusCode; |
|
37 | 39 | $this->reasonPhrase = $reasonPhrase; |
|
38 | 39 | parent::__construct($reasonPhrase, $statusCode, $previous); |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * @return int |
||
43 | */ |
||
44 | 35 | public function getStatusCode(): int |
|
45 | { |
||
46 | 35 | return $this->statusCode; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * @return string |
||
51 | */ |
||
52 | 35 | public function getReasonPhrase(): string |
|
53 | { |
||
54 | 35 | return $this->reasonPhrase; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return string |
||
59 | */ |
||
60 | 26 | public function getTitle(): string |
|
63 | } |
||
64 | } |
||
65 |