| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 2 | protected function run( |
|
| 25 | ServerRequestInterface $request, |
||
| 26 | ResponseInterface $response, |
||
| 27 | array $args |
||
| 28 | ): ResponseInterface { |
||
| 29 | 2 | $list = []; |
|
| 30 | |||
| 31 | 2 | $artistId = (int) ($args['artistId'] ?? 0); |
|
| 32 | |||
| 33 | 2 | $artist = $this->artistRepository->find($artistId); |
|
| 34 | |||
| 35 | 2 | if ($artist === null) { |
|
| 36 | 1 | return $response->withStatus(StatusCode::NOT_FOUND); |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | $result = $this->songRepository->getTopSongsByArtist($artist); |
|
| 40 | |||
| 41 | 1 | foreach ($result as $song) { |
|
| 42 | 1 | $list[] = $this->resultItemFactory->createSongListItem($song, $song->getAlbum()); |
|
| 43 | } |
||
| 44 | |||
| 45 | 1 | return $this->asJson($response, ['items' => $list]); |
|
| 46 | } |
||
| 48 |