Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
23 | 9 | public function __invoke(Resourceful $app, Request $request) |
|
24 | { |
||
25 | 9 | if (!$this->service->contains($request->getRequestUri())) { |
|
26 | 3 | throw new NotFoundHttpException("Not Found"); |
|
27 | } |
||
28 | |||
29 | 6 | $resource = $this->service->fetch($request->getRequestUri()); |
|
30 | 6 | if ($resource === false) { |
|
31 | 1 | throw new ServiceUnavailableHttpException(null, "Failed to retrieve resource"); |
|
32 | } |
||
33 | |||
34 | 5 | $response = JsonResponse::create($resource); |
|
35 | 5 | $response->headers->set("Content-Type", $this->contentType); |
|
36 | |||
37 | 5 | return $app["allow"]($request, $response, $app); |
|
38 | } |
||
39 | } |
||
40 |