Total Complexity | 5 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 14.29% |
Changes | 0 |
1 | <?php |
||
21 | final class PhpLastErrorShutdownHandler implements ShutdownHandlerInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var PhpErrorHandlerInterface |
||
25 | */ |
||
26 | private $phpErrorHandler; |
||
27 | |||
28 | /** |
||
29 | * PhpLastErrorShutdownHandler constructor. |
||
30 | * |
||
31 | * @param PhpErrorHandlerInterface $phpErrorHandler |
||
32 | */ |
||
33 | 17 | public function __construct( |
|
37 | 17 | } |
|
38 | |||
39 | /** |
||
40 | * Handle last php error |
||
41 | */ |
||
42 | public function handleShutdown(): void |
||
43 | { |
||
44 | $error = \error_get_last(); |
||
45 | |||
46 | if (!\is_array($error) || !$this->isCatchableFatalError($error['type'])) { |
||
47 | return; |
||
48 | } |
||
49 | |||
50 | $this->phpErrorHandler->handlePhpError( |
||
51 | $error['type'], |
||
52 | $error['message'], |
||
53 | $error['file'], |
||
54 | $error['line'] |
||
55 | ); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param int $level |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | private function isCatchableFatalError(int $level) |
||
73 | } |
||
74 | } |
||
75 |