Passed
Branch main (69b1a6)
by Daniel
12:24
created

ResponderFactory::createAlbumResponder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 7
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 Traversable;
8
use Usox\HyperSonic\Response\ResponderInterface;
9
10
final class ResponderFactory implements ResponderFactoryInterface
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 1
    public function createArtistsResponder(
29
        array $artistList
30
    ): ResponderInterface {
31 1
        return new ArtistsResponder(
32
            $artistList,
33
        );
34
    }
35
36
    /**
37
     * @param array{
38
     *  valid: string,
39
     *  email: string,
40
     *  licenseExpires: string
41
     * } $licenseData
42
     */
43 1
    public function createLicenseResponder(
44
        array $licenseData
45
    ): ResponderInterface {
46 1
        return new LicenseResponder(
47
            $licenseData,
48
        );
49
    }
50
51 1
    public function createPingResponder(): ResponderInterface
52
    {
53 1
        return new PingResponder();
54
    }
55
56 1
    public function createCoverArtResponder(
57
        string $coverArt,
58
        string $contentType,
59
    ): ResponderInterface {
60 1
        return new CoverArtResponder(
61
            $coverArt,
62
            $contentType,
63
        );
64
    }
65
66
    /**
67
     * @param array{
68
     *  id: string,
69
     *  name: string,
70
     *  coverArt: string,
71
     *  albumCount: int,
72
     *  artistImageUrl: string,
73
     * } $artist
74
     * @param array<array{
75
     *  id: string,
76
     *  name: string,
77
     *  coverArt: string,
78
     *  songCount: int,
79
     *  created: string,
80
     *  duration: int,
81
     *  artist: string,
82
     *  artistId: string,
83
     *  year: string,
84
     *  genre: string,
85
     *  playCount: int
86
     * }> $albums
87
     */
88 1
    public function createArtistResponder(
89
        array $artist,
90
        array $albums,
91
    ): ResponderInterface {
92 1
        return new ArtistResponder($artist, $albums);
93
    }
94
95
    /**
96
     * @param array{
97
     *  id: string,
98
     *  name: string,
99
     *  coverArt: string,
100
     *  songCount: int,
101
     *  created: string,
102
     *  duration: int,
103
     *  artist: string,
104
     *  artistId: string,
105
     * } $album
106
     * @param array<array{
107
     *  id: string,
108
     *  isDir: bool,
109
     *  title: string,
110
     *  album: string,
111
     *  artist: string,
112
     *  track: int,
113
     *  coverArt: string,
114
     *  size: int,
115
     *  contentType: string,
116
     *  duration: int,
117
     *  created: string,
118
     *  albumId: string,
119
     *  artistId: string,
120
     *  playCount: int,
121
     * }> $songs
122
     */
123 1
    public function createAlbumResponder(
124
        array $album,
125
        array $songs,
126
    ): ResponderInterface {
127 1
        return new AlbumResponder(
128
            $album,
129
            $songs
130
        );
131
    }
132
133
    /**
134
     * @param array<array{
135
     *  value: string,
136
     *  albumCount: int,
137
     *  songCount: int
138
     * }> $genres
139
     */
140 1
    public function createGenresResponder(
141
        array $genres,
142
    ): ResponderInterface {
143 1
        return new GenresResponder(
144
            $genres
145
        );
146
    }
147
148
    /**
149
     * @param Traversable<array{
150
     *  name: string,
151
     *  id: string
152
     * }> $musicFolders
153
     */
154 1
    public function createMusicFoldersResponder(
155
        Traversable $musicFolders
156
    ): ResponderInterface {
157 1
        return new MusicFoldersResponder(
158
            $musicFolders
159
        );
160
    }
161
}
162