| Total Complexity | 6 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | final class ArtistsResponder implements FormattedResponderInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @param array{ |
||
| 14 | * ignoredArticles: string, |
||
| 15 | * index: array<array{ |
||
| 16 | * name: string, |
||
| 17 | * artist: array<array{ |
||
| 18 | * id: string, |
||
| 19 | * name: string, |
||
| 20 | * coverArt: string, |
||
| 21 | * artistImageUrl: string, |
||
| 22 | * albumCount: int, |
||
| 23 | * starred?: string |
||
| 24 | * }> |
||
| 25 | * }> |
||
| 26 | * } $artistList |
||
| 27 | */ |
||
| 28 | 4 | public function __construct( |
|
| 29 | private readonly array $artistList |
||
| 30 | ) { |
||
| 31 | 4 | } |
|
| 32 | |||
| 33 | 1 | public function writeXml(XMLArray $XMLArray): void |
|
| 34 | { |
||
| 35 | 1 | $XMLArray->startLoop( |
|
| 36 | 1 | 'artists', |
|
| 37 | 1 | ['ignoredArticles' => $this->artistList['ignoredArticles']], |
|
| 38 | 1 | function (XMLArray $XMLArray): void { |
|
| 39 | 1 | foreach ($this->artistList['index'] as $indexItem) { |
|
| 40 | 1 | $XMLArray->startLoop( |
|
| 41 | 1 | 'index', |
|
| 42 | 1 | ['name' => $indexItem['name']], |
|
| 43 | 1 | static function (XMLArray $XMLArray) use ($indexItem): void { |
|
| 44 | 1 | foreach ($indexItem['artist'] as $artist) { |
|
| 45 | 1 | $XMLArray->add( |
|
| 46 | 1 | 'artist', |
|
| 47 | 1 | null, |
|
| 48 | 1 | $artist |
|
| 49 | 1 | ); |
|
| 50 | } |
||
| 51 | 1 | } |
|
| 52 | 1 | ); |
|
| 53 | } |
||
| 54 | 1 | } |
|
| 55 | 1 | ); |
|
| 56 | } |
||
| 57 | |||
| 58 | 1 | public function writeJson(array &$root): void |
|
| 61 | } |
||
| 62 | |||
| 63 | 1 | public function isBinaryResponder(): bool |
|
| 66 | } |
||
| 67 | } |
||
| 68 |