1 | <?php |
||
14 | class ExceptionHandlerRepository |
||
15 | { |
||
16 | /** |
||
17 | * List of handlers reporting exceptions |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $reporters = []; |
||
22 | |||
23 | /** |
||
24 | * List of handlers rendering exceptions |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $renderers = []; |
||
29 | |||
30 | /** |
||
31 | * List of handlers rendering exceptions to the console |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $consoleRenderers = []; |
||
36 | |||
37 | /** |
||
38 | * Register a custom handler to report exceptions |
||
39 | * |
||
40 | * @param Closure $reporter |
||
41 | * |
||
42 | * @return int |
||
43 | */ |
||
44 | public function addReporter(Closure $reporter): int |
||
48 | |||
49 | /** |
||
50 | * Register a custom handler to render exceptions |
||
51 | * |
||
52 | * @param Closure $renderer |
||
53 | * |
||
54 | * @return int |
||
55 | */ |
||
56 | public function addRenderer(Closure $renderer): int |
||
60 | |||
61 | /** |
||
62 | * Register a custom handler to render exceptions to the console |
||
63 | * |
||
64 | * @param Closure $renderer |
||
65 | * |
||
66 | * @return int |
||
67 | */ |
||
68 | public function addConsoleRenderer(Closure $renderer): int |
||
72 | |||
73 | /** |
||
74 | * Retrieve all the reporters that handle the given exception |
||
75 | * |
||
76 | * @param Exception $e |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | public function getReportersFor(Exception $e): array |
||
84 | |||
85 | /** |
||
86 | * Retrieve the filter to get only handlers that handle the given exception |
||
87 | * |
||
88 | * @param Exception $e |
||
89 | * |
||
90 | * @return Closure |
||
91 | */ |
||
92 | protected function handlesException(Exception $e): Closure |
||
104 | |||
105 | /** |
||
106 | * Retrieve all the renderers that handle the given exception |
||
107 | * |
||
108 | * @param Exception $e |
||
109 | * |
||
110 | * @return array |
||
111 | */ |
||
112 | public function getRenderersFor(Exception $e): array |
||
116 | |||
117 | /** |
||
118 | * Retrieve all the renderers for console that handle the given exception |
||
119 | * |
||
120 | * @param Exception $e |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | public function getConsoleRenderersFor(Exception $e): array |
||
128 | } |
||
129 |