Passed
Push — main ( 69b1a6...b43944 )
by Daniel
02:36
created

ResponderFactory::createStreamResponder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
            $artistList,
34
        );
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
            $licenseData,
49
        );
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
            $coverArt,
63
            $contentType,
64
        );
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
            $album,
130
            $songs
131
        );
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
            $genres
146
        );
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
            $musicFolders
160
        );
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
            $streamData,
175
        );
176
    }
177
}
178