|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Usox\HyperSonic\FeatureSet\V1161\Responder; |
|
6
|
|
|
|
|
7
|
|
|
use Psr\Http\Message\StreamInterface; |
|
8
|
|
|
use Traversable; |
|
9
|
|
|
use Usox\HyperSonic\Response\ResponderInterface; |
|
10
|
|
|
|
|
11
|
|
|
final class ResponderFactory implements ResponderFactoryInterface |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @param array{ |
|
15
|
|
|
* ignoredArticles: string, |
|
16
|
|
|
* index: array<array{ |
|
17
|
|
|
* name: string, |
|
18
|
|
|
* artist: array<array{ |
|
19
|
|
|
* id: string, |
|
20
|
|
|
* name: string, |
|
21
|
|
|
* coverArt: string, |
|
22
|
|
|
* artistImageUrl: string, |
|
23
|
|
|
* albumCount: int, |
|
24
|
|
|
* starred?: string |
|
25
|
|
|
* }> |
|
26
|
|
|
* }> |
|
27
|
|
|
* } $artistList |
|
28
|
|
|
*/ |
|
29
|
1 |
|
public function createArtistsResponder( |
|
30
|
|
|
array $artistList |
|
31
|
|
|
): ResponderInterface { |
|
32
|
1 |
|
return new ArtistsResponder( |
|
33
|
1 |
|
$artistList, |
|
34
|
1 |
|
); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param array{ |
|
39
|
|
|
* valid: string, |
|
40
|
|
|
* email: string, |
|
41
|
|
|
* licenseExpires: string |
|
42
|
|
|
* } $licenseData |
|
43
|
|
|
*/ |
|
44
|
1 |
|
public function createLicenseResponder( |
|
45
|
|
|
array $licenseData |
|
46
|
|
|
): ResponderInterface { |
|
47
|
1 |
|
return new LicenseResponder( |
|
48
|
1 |
|
$licenseData, |
|
49
|
1 |
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
1 |
|
public function createPingResponder(): ResponderInterface |
|
53
|
|
|
{ |
|
54
|
1 |
|
return new PingResponder(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
1 |
|
public function createCoverArtResponder( |
|
58
|
|
|
string $coverArt, |
|
59
|
|
|
string $contentType, |
|
60
|
|
|
): ResponderInterface { |
|
61
|
1 |
|
return new CoverArtResponder( |
|
62
|
1 |
|
$coverArt, |
|
63
|
1 |
|
$contentType, |
|
64
|
1 |
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param array{ |
|
69
|
|
|
* id: string, |
|
70
|
|
|
* name: string, |
|
71
|
|
|
* coverArt: string, |
|
72
|
|
|
* albumCount: int, |
|
73
|
|
|
* artistImageUrl: string, |
|
74
|
|
|
* } $artist |
|
75
|
|
|
* @param array<array{ |
|
76
|
|
|
* id: string, |
|
77
|
|
|
* name: string, |
|
78
|
|
|
* coverArt: string, |
|
79
|
|
|
* songCount: int, |
|
80
|
|
|
* created: string, |
|
81
|
|
|
* duration: int, |
|
82
|
|
|
* artist: string, |
|
83
|
|
|
* artistId: string, |
|
84
|
|
|
* year: string, |
|
85
|
|
|
* genre: string, |
|
86
|
|
|
* playCount: int |
|
87
|
|
|
* }> $albums |
|
88
|
|
|
*/ |
|
89
|
1 |
|
public function createArtistResponder( |
|
90
|
|
|
array $artist, |
|
91
|
|
|
array $albums, |
|
92
|
|
|
): ResponderInterface { |
|
93
|
1 |
|
return new ArtistResponder($artist, $albums); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param array{ |
|
98
|
|
|
* id: string, |
|
99
|
|
|
* name: string, |
|
100
|
|
|
* coverArt: string, |
|
101
|
|
|
* songCount: int, |
|
102
|
|
|
* created: string, |
|
103
|
|
|
* duration: int, |
|
104
|
|
|
* artist: string, |
|
105
|
|
|
* artistId: string, |
|
106
|
|
|
* } $album |
|
107
|
|
|
* @param array<array{ |
|
108
|
|
|
* id: string, |
|
109
|
|
|
* isDir: bool, |
|
110
|
|
|
* title: string, |
|
111
|
|
|
* album: string, |
|
112
|
|
|
* artist: string, |
|
113
|
|
|
* track: int, |
|
114
|
|
|
* coverArt: string, |
|
115
|
|
|
* size: int, |
|
116
|
|
|
* contentType: string, |
|
117
|
|
|
* duration: int, |
|
118
|
|
|
* created: string, |
|
119
|
|
|
* albumId: string, |
|
120
|
|
|
* artistId: string, |
|
121
|
|
|
* playCount: int, |
|
122
|
|
|
* }> $songs |
|
123
|
|
|
*/ |
|
124
|
1 |
|
public function createAlbumResponder( |
|
125
|
|
|
array $album, |
|
126
|
|
|
array $songs, |
|
127
|
|
|
): ResponderInterface { |
|
128
|
1 |
|
return new AlbumResponder( |
|
129
|
1 |
|
$album, |
|
130
|
1 |
|
$songs |
|
131
|
1 |
|
); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @param array<array{ |
|
136
|
|
|
* value: string, |
|
137
|
|
|
* albumCount: int, |
|
138
|
|
|
* songCount: int |
|
139
|
|
|
* }> $genres |
|
140
|
|
|
*/ |
|
141
|
1 |
|
public function createGenresResponder( |
|
142
|
|
|
array $genres, |
|
143
|
|
|
): ResponderInterface { |
|
144
|
1 |
|
return new GenresResponder( |
|
145
|
1 |
|
$genres |
|
146
|
1 |
|
); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @param Traversable<array{ |
|
151
|
|
|
* name: string, |
|
152
|
|
|
* id: string |
|
153
|
|
|
* }> $musicFolders |
|
154
|
|
|
*/ |
|
155
|
1 |
|
public function createMusicFoldersResponder( |
|
156
|
|
|
Traversable $musicFolders |
|
157
|
|
|
): ResponderInterface { |
|
158
|
1 |
|
return new MusicFoldersResponder( |
|
159
|
1 |
|
$musicFolders |
|
160
|
1 |
|
); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @param array{ |
|
165
|
|
|
* contentType: string, |
|
166
|
|
|
* length: int, |
|
167
|
|
|
* stream: StreamInterface, |
|
168
|
|
|
* } $streamData |
|
169
|
|
|
*/ |
|
170
|
1 |
|
public function createStreamResponder( |
|
171
|
|
|
array $streamData, |
|
172
|
|
|
): ResponderInterface { |
|
173
|
1 |
|
return new StreamResponder( |
|
174
|
1 |
|
$streamData, |
|
175
|
1 |
|
); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @param Traversable<array{ |
|
180
|
|
|
* id: string, |
|
181
|
|
|
* name: string, |
|
182
|
|
|
* coverArt: string, |
|
183
|
|
|
* songCount: int, |
|
184
|
|
|
* created: string, |
|
185
|
|
|
* duration: int, |
|
186
|
|
|
* artist: string, |
|
187
|
|
|
* artistId: string, |
|
188
|
|
|
* }> $albumList |
|
189
|
|
|
*/ |
|
190
|
1 |
|
public function createAlbumList2Responder( |
|
191
|
|
|
Traversable $albumList |
|
192
|
|
|
): ResponderInterface { |
|
193
|
1 |
|
return new AlbumList2Responder($albumList); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* @param Traversable<array{ |
|
198
|
|
|
* id: string, |
|
199
|
|
|
* title: string, |
|
200
|
|
|
* album: string, |
|
201
|
|
|
* artist: string, |
|
202
|
|
|
* coverArt: string, |
|
203
|
|
|
* albumId: string, |
|
204
|
|
|
* artistId: string, |
|
205
|
|
|
* duration: int, |
|
206
|
|
|
* created: string, |
|
207
|
|
|
* starred: string, |
|
208
|
|
|
* size: int |
|
209
|
|
|
* }> $songs |
|
210
|
|
|
* @param Traversable<array{ |
|
211
|
|
|
* id: string, |
|
212
|
|
|
* name: string, |
|
213
|
|
|
* artist: string, |
|
214
|
|
|
* artistId: string, |
|
215
|
|
|
* songCount: int, |
|
216
|
|
|
* coverArt: string, |
|
217
|
|
|
* duration: int, |
|
218
|
|
|
* created: string, |
|
219
|
|
|
* starred: string, |
|
220
|
|
|
* year: int |
|
221
|
|
|
* }> $albums |
|
222
|
|
|
*/ |
|
223
|
1 |
|
public function createStarred2Responder( |
|
224
|
|
|
Traversable $songs, |
|
225
|
|
|
Traversable $albums, |
|
226
|
|
|
): ResponderInterface { |
|
227
|
1 |
|
return new GetStarred2Responder( |
|
228
|
1 |
|
$songs, |
|
229
|
1 |
|
$albums |
|
230
|
1 |
|
); |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* @param Traversable<array{ |
|
235
|
|
|
* id: string, |
|
236
|
|
|
* parent: string, |
|
237
|
|
|
* title: string, |
|
238
|
|
|
* isDir: string, |
|
239
|
|
|
* album: string, |
|
240
|
|
|
* artist: string, |
|
241
|
|
|
* track: int, |
|
242
|
|
|
* year: int, |
|
243
|
|
|
* coverArt: string, |
|
244
|
|
|
* duration: int, |
|
245
|
|
|
* size: int |
|
246
|
|
|
* }> $songs |
|
247
|
|
|
*/ |
|
248
|
1 |
|
public function createRandomSongsResponder( |
|
249
|
|
|
Traversable $songs |
|
250
|
|
|
): ResponderInterface { |
|
251
|
1 |
|
return new GetRandomSongsResponder( |
|
252
|
1 |
|
$songs |
|
253
|
1 |
|
); |
|
254
|
|
|
} |
|
255
|
|
|
} |
|
256
|
|
|
|