| Total Complexity | 5 | 
| Total Lines | 63 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 10 | final class AlbumResponder implements FormattedResponderInterface | ||
| 11 | { | ||
| 12 | /** | ||
| 13 |      * @param array{ | ||
| 14 | * id: string, | ||
| 15 | * name: string, | ||
| 16 | * coverArt: string, | ||
| 17 | * songCount: int, | ||
| 18 | * created: string, | ||
| 19 | * duration: int, | ||
| 20 | * artist: string, | ||
| 21 | * artistId: string, | ||
| 22 | * } $album | ||
| 23 |      * @param array<array{ | ||
| 24 | * id: string, | ||
| 25 | * isDir: bool, | ||
| 26 | * title: string, | ||
| 27 | * album: string, | ||
| 28 | * artist: string, | ||
| 29 | * track: int, | ||
| 30 | * coverArt: string, | ||
| 31 | * size: int, | ||
| 32 | * contentType: string, | ||
| 33 | * duration: int, | ||
| 34 | * created: string, | ||
| 35 | * albumId: string, | ||
| 36 | * artistId: string, | ||
| 37 | * playCount: int, | ||
| 38 | * }> $songs | ||
| 39 | */ | ||
| 40 | 4 | public function __construct( | |
| 41 | private readonly array $album, | ||
| 42 | private readonly array $songs, | ||
| 43 |     ) { | ||
| 44 | } | ||
| 45 | |||
| 46 | 1 | public function writeXml(XMLArray $XMLArray): void | |
| 47 |     { | ||
| 48 | 1 | $albumNode = $XMLArray->start( | |
| 49 | 'album', | ||
| 50 | 1 | $this->album, | |
| 51 | ); | ||
| 52 | |||
| 53 | 1 |         foreach ($this->songs as $song) { | |
| 54 | 1 | $albumNode->add( | |
| 55 | 'song', | ||
| 56 | null, | ||
| 57 | $song | ||
| 58 | ); | ||
| 59 | } | ||
| 60 | |||
| 61 | 1 | $albumNode->end(); | |
| 62 | } | ||
| 63 | |||
| 64 | 1 | public function writeJson(array &$root): void | |
| 65 |     { | ||
| 66 | 1 | $root['album'] = $this->album; | |
| 67 | 1 | $root['album']['song'] = $this->songs; | |
| 68 | } | ||
| 69 | |||
| 70 | 1 | public function isBinaryResponder(): bool | |
| 73 | } | ||
| 74 | } | ||
| 75 |