| Conditions | 3 |
| Paths | 1 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function register(Container $container) |
||
| 16 | { |
||
| 17 | $container['errorHandler'] = function (Container $c) { |
||
|
|
|||
| 18 | return function($request, $response, $exception) use ($c) { |
||
| 19 | $details = (defined('DEBUG_MODE') && DEBUG_MODE == 1) ? $exception->getMessage() : 'Internal server error'; |
||
| 20 | $e = new JsonException(null, 500, 'Internal server error', $details); |
||
| 21 | |||
| 22 | return $c->get('renderer')->jsonApiRender($response, $e->statusCode, $e->encodeError()); |
||
| 23 | }; |
||
| 24 | }; |
||
| 25 | |||
| 26 | $container['notAllowedHandler'] = function (Container $c) { |
||
| 27 | return function($request, $response, $methods) use ($c) { |
||
| 28 | throw new JsonException(null, 405, 'Method Not Allowed', 'Method must be one of: '.implode(', ', $methods)); |
||
| 29 | }; |
||
| 30 | }; |
||
| 31 | |||
| 32 | $container['notFoundHandler'] = function (Container $c) { |
||
| 33 | return function() use ($c) { |
||
| 34 | throw new JsonException(null, 404, 'Not found', 'Entity not found'); |
||
| 35 | }; |
||
| 36 | }; |
||
| 37 | |||
| 38 | } |
||
| 39 | } |
||
| 40 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.