| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | 1 | protected function run( |
|
| 28 | ServerRequestInterface $request, |
||
| 29 | JsonEnabledResponseInterface $response, |
||
| 30 | array $args |
||
| 31 | ): ResponseInterface { |
||
| 32 | 1 | $mostPlayed = $this->playbackHistoryRepository->getMostPlayed(); |
|
| 33 | |||
| 34 | 1 | $result = []; |
|
| 35 | |||
| 36 | 1 | foreach ($mostPlayed as $item) { |
|
| 37 | 1 | $song = $this->songRepository->find($item['song_id']); |
|
| 38 | 1 | if ($song === null) { |
|
| 39 | 1 | continue; |
|
| 40 | } |
||
| 41 | |||
| 42 | 1 | $result[] = [ |
|
| 43 | 1 | 'count' => $item['cnt'], |
|
| 44 | 1 | 'song' => $this->resultItemFactory->createSongListItem($song, $song->getAlbum()), |
|
| 45 | 1 | ]; |
|
| 46 | } |
||
| 47 | |||
| 48 | 1 | return $response->withJson( |
|
| 49 | 1 | ['items' => $result], |
|
| 50 | 1 | ); |
|
| 53 |