Conditions | 4 |
Paths | 9 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4.3244 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
36 | 1 | public function call(Route $route) |
|
37 | { |
||
38 | try { |
||
39 | 1 | $response = call_user_func($route->getAction(), $this->request, $route->getMergedParams()); |
|
40 | |||
41 | 1 | if (is_array($response)) { |
|
42 | 1 | $this->response->getBody()->write(json_encode($response)); |
|
43 | 1 | $response = $this->response; |
|
44 | 1 | } |
|
45 | |||
46 | 1 | if ($response instanceof ResponseInterface) { |
|
47 | 1 | return $response->withAddedHeader("content-type", "application/json"); |
|
48 | } |
||
49 | } catch (HttpExceptionAbstract $e) { |
||
50 | return $e->getJsonResponse($this->response); |
||
51 | } |
||
52 | |||
53 | throw new RuntimeException("Unable to determine a json response from action returned value."); |
||
54 | } |
||
55 | |||
57 |