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