| Conditions | 2 |
| Paths | 2 |
| Total Lines | 30 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | protected function run( |
||
| 22 | ServerRequestInterface $request, |
||
| 23 | ResponseInterface $response, |
||
| 24 | array $args |
||
| 25 | ): ResponseInterface { |
||
| 26 | $history = $this->playbackHistoryRepository->findBy( |
||
| 27 | [], |
||
| 28 | ['play_date' => 'DESC'], |
||
| 29 | static::HISTORY_LIMIT |
||
| 30 | ); |
||
| 31 | |||
| 32 | $result = []; |
||
| 33 | |||
| 34 | foreach ($history as $item) { |
||
| 35 | $song = $item->getSong(); |
||
| 36 | $user = $item->getUser(); |
||
| 37 | |||
| 38 | $result[] = [ |
||
| 39 | 'songId' => $song->getId(), |
||
| 40 | 'songName' => $song->getTitle(), |
||
| 41 | 'songArtistName' => $song->getArtist()->getTitle(), |
||
| 42 | 'userId' => $user->getId(), |
||
| 43 | 'userName' => $user->getName(), |
||
| 44 | 'playDate' => $item->getPlayDate()->getTimestamp(), |
||
| 45 | ]; |
||
| 46 | } |
||
| 47 | |||
| 48 | return $this->asJson( |
||
| 49 | $response, |
||
| 50 | $result, |
||
| 51 | ); |
||
| 54 |