Total Complexity | 6 |
Total Lines | 74 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | abstract class BaseException extends Exception |
||
9 | { |
||
10 | /** |
||
11 | * @var int |
||
12 | */ |
||
13 | protected $statusCode; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $error; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $description; |
||
24 | |||
25 | /** |
||
26 | * BaseException constructor. |
||
27 | * |
||
28 | * @param int $statusCode |
||
29 | * @param string $error |
||
30 | * @param string $description |
||
31 | * @param int $code |
||
32 | * @param Exception|null $previous |
||
33 | */ |
||
34 | public function __construct(int $statusCode, string $error, string $description, $code = 0, Exception $previous = null) |
||
35 | { |
||
36 | $message = $this->toString($statusCode, $error, $description); |
||
37 | |||
38 | parent::__construct($message, $code, $previous); |
||
39 | |||
40 | $this->statusCode = $statusCode; |
||
41 | $this->error = $error; |
||
42 | $this->description = $description; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @return int |
||
47 | */ |
||
48 | public function getStatusCode() |
||
49 | { |
||
50 | return $this->statusCode; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getError(): string |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getDescription(): string |
||
65 | { |
||
66 | return $this->description; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param string $statusCode |
||
71 | * @param string $error |
||
72 | * @param string $description |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | protected function toString(int $statusCode, string $error, string $description): string |
||
82 | } |
||
83 | } |