1 | <?php |
||
10 | final class ErrorHandler implements \Nofw\Error\ErrorHandler |
||
11 | { |
||
12 | /** |
||
13 | * Default context values. |
||
14 | */ |
||
15 | private $context = []; |
||
16 | |||
17 | /** |
||
18 | * @var ErrorHandler[] |
||
19 | */ |
||
20 | private $handlers = []; |
||
21 | |||
22 | /** |
||
23 | * @var Processor[] |
||
24 | */ |
||
25 | private $processors = []; |
||
26 | |||
27 | public function __construct(array $context = []) |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public function handle(\Throwable $t, array $context = []): void |
||
49 | |||
50 | /** |
||
51 | * Pushes a handler on to the stack. |
||
52 | * |
||
53 | * @param \Nofw\Error\ErrorHandler $handler |
||
54 | * |
||
55 | * @return ErrorHandler |
||
56 | */ |
||
57 | public function pushHandler(\Nofw\Error\ErrorHandler $handler): self |
||
63 | |||
64 | /** |
||
65 | * Pops a handler from the stack. |
||
66 | * |
||
67 | * @return \Nofw\Error\ErrorHandler |
||
68 | * |
||
69 | * @throws \LogicException If the handler stack is empty |
||
70 | */ |
||
71 | public function popHandler(): \Nofw\Error\ErrorHandler |
||
79 | |||
80 | /** |
||
81 | * @return ErrorHandler[] |
||
82 | */ |
||
83 | public function getHandlers(): array |
||
87 | |||
88 | /** |
||
89 | * @param ErrorHandler[] $handlers |
||
90 | * |
||
91 | * @return ErrorHandler |
||
92 | */ |
||
93 | public function setHandlers(array $handlers): self |
||
103 | |||
104 | /** |
||
105 | * Pushes a processor on to the stack. |
||
106 | * |
||
107 | * @param Processor $processor |
||
108 | * |
||
109 | * @return ErrorHandler |
||
110 | */ |
||
111 | public function pushProcessor(Processor $processor): self |
||
117 | |||
118 | /** |
||
119 | * Pops a processor from the stack. |
||
120 | * |
||
121 | * @return Processor |
||
122 | * |
||
123 | * @throws \LogicException If the processor stack is empty |
||
124 | */ |
||
125 | public function popProcessor(): Processor |
||
133 | |||
134 | /** |
||
135 | * @return Processor[] |
||
136 | */ |
||
137 | public function getProcessors(): array |
||
141 | |||
142 | /** |
||
143 | * @param Processor[] $processors |
||
144 | * |
||
145 | * @return ErrorHandler |
||
146 | */ |
||
147 | public function setProcessors(array $processors): self |
||
157 | } |
||
158 |