| Total Complexity | 3 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | final class CoverArtDataProvider implements GetCoverArtDataProviderInterface |
||
| 17 | { |
||
| 18 | 2 | public function __construct( |
|
| 19 | private readonly ArtistRepositoryInterface $artistRepository, |
||
|
|
|||
| 20 | private readonly ArtContentRetrieverInterface $artContentRetriever, |
||
| 21 | ) { |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @return array{ |
||
| 26 | * contentType: string, |
||
| 27 | * art: string |
||
| 28 | * } |
||
| 29 | */ |
||
| 30 | 2 | public function getArt(string $coverArtId): array |
|
| 31 | { |
||
| 32 | // @todo Currently artists only; Merge with Api\Art\ArtApplication |
||
| 33 | 2 | $str = explode('-', $coverArtId); |
|
| 34 | |||
| 35 | /** @var ArtistInterface $artist */ |
||
| 36 | 2 | $artist = $this->artistRepository->find((int) $str[1]); |
|
| 37 | |||
| 38 | try { |
||
| 39 | 2 | $artContent = $this->artContentRetriever->retrieve($artist); |
|
| 40 | 1 | } catch (ArtContentException) { |
|
| 41 | 1 | $artContent = []; |
|
| 42 | } |
||
| 43 | |||
| 44 | return [ |
||
| 45 | 2 | 'art' => $artContent['content'] ?? '', |
|
| 46 | 2 | 'contentType' => $artContent['mimeType'] ?? '', |
|
| 47 | ]; |
||
| 50 |