Total Complexity | 3 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class CseExceptions extends Exception |
||
15 | { |
||
16 | protected const DEFAULT_ERROR_MSG = 'Unknown error'; |
||
17 | |||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | private static $errorsMsg = []; |
||
22 | |||
23 | /** |
||
24 | * Get error msg |
||
25 | * |
||
26 | * @param int $code |
||
27 | * |
||
28 | * @return string |
||
29 | */ |
||
30 | public static function getErrorMsg(int $code): ?string |
||
31 | { |
||
32 | return static::$errorsMsg[$code] ?? static::DEFAULT_ERROR_MSG; |
||
|
|||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Throw new exception |
||
37 | * |
||
38 | * @param int $code |
||
39 | * @param string|null $msg |
||
40 | * |
||
41 | * @throws CseExceptions |
||
42 | */ |
||
43 | public static function throwException(int $code, ?string $msg = ''): void |
||
46 | } |
||
47 | } |