| Conditions | 3 |
| Paths | 3 |
| Total Lines | 34 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 25 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 43 | 2 | public function getArtist( |
|
| 44 | string $artistId |
||
| 45 | ): ?array { |
||
| 46 | 2 | $artist = $this->artistRepository->find((int) $artistId); |
|
| 47 | |||
| 48 | 2 | if ($artist === null) { |
|
| 49 | 1 | return null; |
|
| 50 | } |
||
| 51 | |||
| 52 | 1 | $albums = []; |
|
| 53 | 1 | $artistName = (string) $artist->getTitle(); |
|
| 54 | |||
| 55 | 1 | foreach ($artist->getAlbums() as $album) { |
|
| 56 | 1 | $albumId = $album->getId(); |
|
| 57 | |||
| 58 | 1 | $albums[] = [ |
|
| 59 | 1 | 'id' => $albumId, |
|
| 60 | 1 | 'name' => (string) $album->getTitle(), |
|
| 61 | 1 | 'coverArtId' => 'album-'.$albumId, |
|
| 62 | 1 | 'songCount' => $album->getSongCount(), |
|
| 63 | 1 | 'createDate' => null, // @todo implement, |
|
| 64 | 1 | 'duration' => $album->getLength(), |
|
| 65 | 1 | 'artistName' => $artistName, |
|
| 66 | 1 | 'artistId' => $artistId, |
|
| 67 | 1 | ]; |
|
| 68 | } |
||
| 69 | |||
| 70 | 1 | return [ |
|
| 71 | 1 | 'id' => $artistId, |
|
| 72 | 1 | 'name' => $artistName, |
|
| 73 | 1 | 'coverArtId' => 'artist-'.$artistId, |
|
| 74 | 1 | 'artistImageUrl' => '', |
|
| 75 | 1 | 'albumCount' => $artist->getAlbumCount(), |
|
| 76 | 1 | 'albums' => $albums, |
|
| 77 | 1 | ]; |
|
| 80 |