Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3.0175 |
Changes | 0 |
1 | <?php |
||
36 | 2 | public function read(Application $app, Request $request) |
|
37 | { |
||
38 | 2 | $datastore = $this->getDatastore($app); |
|
39 | 2 | if (!$datastore->contains($request->getRequestUri())) { |
|
40 | 1 | throw new NotFoundHttpException("Not Found"); |
|
41 | } |
||
42 | |||
43 | 1 | $resource = $datastore->fetch($request->getRequestUri()); |
|
44 | 1 | if ($resource === false) { |
|
45 | throw new ServiceUnavailableHttpException(null, "Failed to retrieve resource"); |
||
46 | } |
||
47 | |||
48 | 1 | return $app->json($resource); |
|
49 | } |
||
50 | } |
||
51 |