Conditions | 6 |
Paths | 15 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 6 |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
16 | * {@inheritdoc} |
||
17 | */ |
||
18 | public function getExecutionChain(Route $route, array $vars) |
||
19 | { |
||
20 | $middleware = function ( |
||
21 | ServerRequestInterface $request, ResponseInterface $response, callable $next |
||
22 | ) use ( |
||
23 | $route, $vars |
||
24 | ) { |
||
25 | try { |
||
26 | $response = call_user_func_array($route->getCallable(), [$request, $response, $vars]); |
||
27 | |||
28 | if (! $response instanceof ResponseInterface) { |
||
29 | throw new RuntimeException( |
||
30 | 'Route callables must return an instance of (Psr\Http\Message\ResponseInterface)' |
||
31 | ); |
||
32 | } |
||
33 | |||
34 | $response = $next($request, $response); |
||
35 | } catch (HttpException $e) { |
||
36 | $response = $e->buildJsonResponse($response); |
||
37 | } catch (Exception $e) { |
||
38 | $body = [ |
||
39 | 'code' => 500, |
||
40 | 'message' => $e->getMessage() |
||
41 | ]; |
||
42 | |||
59 |