| Total Complexity | 6 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class ErrorHandler |
||
| 9 | { |
||
| 10 | |||
| 11 | private $errorPagePath = ''; |
||
| 12 | |||
| 13 | public function register() |
||
| 14 | { |
||
| 15 | (new Run())->pushHandler(\ENV === 'dev' |
||
|
|
|||
| 16 | ? new PrettyPageHandler() |
||
| 17 | : function () { |
||
| 18 | $errorPagePath = $this->getErrorPagePath(); |
||
| 19 | if ($errorPagePath && \file_exists($errorPagePath)) { |
||
| 20 | echo \file_get_contents($errorPagePath); |
||
| 21 | } else { |
||
| 22 | echo 'System error'; |
||
| 23 | } |
||
| 24 | })->register(); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @return string |
||
| 29 | */ |
||
| 30 | public function getErrorPagePath(): string |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $errorPagePath |
||
| 37 | */ |
||
| 38 | public function setErrorPagePath(string $errorPagePath) |
||
| 43 |