| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | public function __invoke(Request $request, Response $response, \Exception $exception) |
||
| 11 | { |
||
| 12 | $status = $exception->getCode() ?: 500; |
||
| 13 | $data = [ |
||
| 14 | "status" => "error", |
||
| 15 | "message" => $exception->getMessage(), |
||
| 16 | ]; |
||
| 17 | $body = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); |
||
| 18 | return $response |
||
| 19 | ->withStatus($status) |
||
| 20 | ->withHeader("Content-type", "application/json") |
||
| 21 | ->write($body); |
||
| 22 | } |
||
| 23 | } |
||
| 24 |