| Total Complexity | 6 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final readonly class ArtistHandler implements HandlerInterface |
||
|
|
|||
| 13 | { |
||
| 14 | 1 | public function __construct( |
|
| 15 | private ArtistRepositoryInterface $artistRepository, |
||
| 16 | ) { |
||
| 17 | 1 | } |
|
| 18 | |||
| 19 | /** |
||
| 20 | * Adds all eligible song ids of the artists' album to the songList array |
||
| 21 | * |
||
| 22 | * @param array<int> $songList |
||
| 23 | */ |
||
| 24 | 1 | public function handle(int $mediaId, array &$songList): void |
|
| 25 | { |
||
| 26 | 1 | $artist = $this->artistRepository->find($mediaId); |
|
| 27 | 1 | if ($artist !== null) { |
|
| 28 | 1 | foreach ($artist->getAlbums() as $album) { |
|
| 29 | 1 | foreach ($album->getDiscs() as $disc) { |
|
| 30 | 1 | foreach ($disc->getSongs() as $song) { |
|
| 31 | 1 | $songList[] = $song->getId(); |
|
| 32 | } |
||
| 38 |