1 | <?php |
||
12 | class ErrorHandler |
||
13 | { |
||
14 | const KEY = 'EXCEPTION'; |
||
15 | |||
16 | use Utils\CallableTrait; |
||
17 | use Utils\AttributeTrait; |
||
18 | use Utils\StreamTrait; |
||
19 | |||
20 | /** |
||
21 | * @var callable|string The handler used |
||
22 | */ |
||
23 | private $handler; |
||
24 | |||
25 | /** |
||
26 | * @var callable|null The status code validator |
||
27 | */ |
||
28 | private $statusCodeValidator; |
||
29 | |||
30 | /** |
||
31 | * @var bool Whether or not catch exceptions |
||
32 | */ |
||
33 | private $catchExceptions = false; |
||
34 | |||
35 | /** |
||
36 | * Returns the exception throwed. |
||
37 | * |
||
38 | * @param ServerRequestInterface $request |
||
39 | * |
||
40 | * @return \Exception|null |
||
41 | */ |
||
42 | public static function getException(ServerRequestInterface $request) |
||
46 | |||
47 | /** |
||
48 | * Constructor. |
||
49 | * |
||
50 | * @param callable|string|null $handler |
||
51 | */ |
||
52 | public function __construct($handler = null) |
||
56 | |||
57 | /** |
||
58 | * Configure the catchExceptions. |
||
59 | * |
||
60 | * @param bool $catch |
||
61 | * |
||
62 | * @return self |
||
63 | */ |
||
64 | public function catchExceptions($catch = true) |
||
70 | |||
71 | /** |
||
72 | * Configure the status code validator. |
||
73 | * |
||
74 | * @param callable $statusCodeValidator |
||
75 | * |
||
76 | * @return self |
||
77 | */ |
||
78 | public function statusCode(callable $statusCodeValidator) |
||
84 | |||
85 | /** |
||
86 | * Execute the middleware. |
||
87 | * |
||
88 | * @param ServerRequestInterface $request |
||
89 | * @param ResponseInterface $response |
||
90 | * @param callable $next |
||
91 | * |
||
92 | * @return ResponseInterface |
||
93 | */ |
||
94 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
128 | |||
129 | /** |
||
130 | * Check whether the status code represents an error or not. |
||
131 | * |
||
132 | * @param int $statusCode |
||
133 | * |
||
134 | * @return bool |
||
135 | */ |
||
136 | private function isError($statusCode) |
||
144 | |||
145 | /** |
||
146 | * Default handler. |
||
147 | * |
||
148 | * @param ServerRequestInterface $request |
||
149 | * @param ResponseInterface $response |
||
150 | * |
||
151 | * @return string |
||
152 | */ |
||
153 | private function defaultHandler(ServerRequestInterface $request, ResponseInterface $response) |
||
187 | |||
188 | /** |
||
189 | * Print the error as plain text. |
||
190 | * |
||
191 | * @param int $statusCode |
||
192 | * @param string $message |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | private static function errorText($statusCode, $message) |
||
200 | |||
201 | /** |
||
202 | * Print the error as svg image. |
||
203 | * |
||
204 | * @param int $statusCode |
||
205 | * @param string $message |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | private static function errorSvg($statusCode, $message) |
||
219 | |||
220 | /** |
||
221 | * Print the error as html. |
||
222 | * |
||
223 | * @param int $statusCode |
||
224 | * @param string $message |
||
225 | * |
||
226 | * @return string |
||
227 | */ |
||
228 | private static function errorHtml($statusCode, $message) |
||
246 | |||
247 | /** |
||
248 | * Print the error as image. |
||
249 | * |
||
250 | * @param int $statusCode |
||
251 | * @param string $message |
||
252 | * @param string $output |
||
253 | * |
||
254 | * @return string |
||
255 | */ |
||
256 | private static function errorImage($statusCode, $message, $output) |
||
272 | |||
273 | /** |
||
274 | * Print the error as json. |
||
275 | * |
||
276 | * @param int $statusCode |
||
277 | * @param string $message |
||
278 | * |
||
279 | * @return string |
||
280 | */ |
||
281 | private static function errorJson($statusCode, $message) |
||
291 | |||
292 | /** |
||
293 | * Print the error as xml. |
||
294 | * |
||
295 | * @param int $statusCode |
||
296 | * @param string $message |
||
297 | * |
||
298 | * @return string |
||
299 | */ |
||
300 | private static function errorXml($statusCode, $message) |
||
310 | } |
||
311 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.