ArtistResponder::isBinaryResponder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Usox\HyperSonic\FeatureSet\V1161\Responder;
6
7
use AaronDDM\XMLBuilder\XMLArray;
8
use Usox\HyperSonic\Response\FormattedResponderInterface;
9
10
final class ArtistResponder implements FormattedResponderInterface
11
{
12
    /**
13
     * @param array{
14
     *  id: string,
15
     *  name: string,
16
     *  coverArt: string,
17
     *  albumCount: int,
18
     *  artistImageUrl: string,
19
     * } $artist
20
     * @param array<array{
21
     *  id: string,
22
     *  name: string,
23
     *  coverArt: string,
24
     *  songCount: int,
25
     *  created: string,
26
     *  duration: int,
27
     *  artist: string,
28
     *  artistId: string,
29
     *  year: string,
30
     *  genre: string,
31
     *  playCount: int
32
     * }> $albums
33
     */
34 4
    public function __construct(
35
        private readonly array $artist,
36
        private readonly array $albums,
37
    ) {
38 4
    }
39
40 1
    public function writeXml(XMLArray $XMLArray): void
41
    {
42 1
        $artistNode = $XMLArray->start(
43 1
            'artist',
44 1
            $this->artist,
45 1
        );
46
47 1
        foreach ($this->albums as $album) {
48 1
            $artistNode->add(
49 1
                'album',
50 1
                null,
51 1
                $album
52 1
            );
53
        }
54
55 1
        $artistNode->end();
56
    }
57
58 1
    public function writeJson(array &$root): void
59
    {
60 1
        $root['artist'] = $this->artist;
61 1
        $root['artist']['album'] = $this->albums;
62
    }
63
64 1
    public function isBinaryResponder(): bool
65
    {
66 1
        return false;
67
    }
68
}
69