Total Complexity | 6 |
Total Lines | 67 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class ConnectionException extends BaseException |
||
8 | { |
||
9 | private static string $before = "<Connection Exception>"; |
||
10 | |||
11 | /** |
||
12 | * Creates a new instance of ConnectionException. |
||
13 | * |
||
14 | * @param string $message |
||
15 | * @param int $code |
||
16 | * @param Exception|null $previous |
||
17 | * @param array $details |
||
18 | * @return self |
||
19 | */ |
||
20 | public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
||
21 | { |
||
22 | return new self(self::getBefore() . ": " . $message, $code, $previous, $details); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Gets the static text that will be prepended to the exception message. |
||
27 | * |
||
28 | * @return string |
||
29 | */ |
||
30 | public static function getBefore(): string |
||
31 | { |
||
32 | return self::$before; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Sets the static text that will be prepended to the exception message. |
||
37 | * |
||
38 | * @param string $text |
||
39 | */ |
||
40 | public static function setBefore(string $text): void |
||
41 | { |
||
42 | self::$before = $text; |
||
43 | } |
||
44 | |||
45 | /* |
||
46 | * Converts the exception to an array representation. |
||
47 | * |
||
48 | * @return array |
||
49 | */ |
||
50 | public function toArray() |
||
51 | { |
||
52 | return parent::toArray(); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Converts the exception to a JSON serializable format. |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | public function jsonSerialize(): array |
||
61 | { |
||
62 | return parent::jsonSerialize(); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Converts the exception to a JSON string. |
||
67 | * |
||
68 | * @param int $options |
||
69 | * @return string |
||
70 | */ |
||
71 | public function toJson(int $options = 0) |
||
74 | } |
||
75 | } |
||
76 |