| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | 2 | protected function run( |
|
| 29 | ServerRequestInterface $request, |
||
| 30 | JsonEnabledResponseInterface $response, |
||
| 31 | array $args |
||
| 32 | ): ResponseInterface { |
||
| 33 | 2 | $genreId = (int) ($args['genreId'] ?? null); |
|
| 34 | |||
| 35 | 2 | $genre = $this->genreRepository->find($genreId); |
|
| 36 | 2 | if ($genre === null) { |
|
| 37 | 1 | return $response->withStatus(Http::NOT_FOUND); |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | $list = []; |
|
| 41 | |||
| 42 | 1 | foreach ($this->albumRepository->findByGenre($genre) as $album) { |
|
| 43 | 1 | $list[] = $this->resultItemFactory->createAlbumListItem($album); |
|
| 44 | } |
||
| 45 | |||
| 46 | 1 | return $response->withJson( |
|
| 47 | 1 | ['items' => $list] |
|
| 48 | 1 | ); |
|
| 51 |