@@ -53,7 +53,7 @@ |
||
53 | 53 | */ |
54 | 54 | public function getAccessByRefreshToken(string $refreshAccessToken) : string |
55 | 55 | { |
56 | - if( $this->session->refreshAccessToken($refreshAccessToken) !== true ) { |
|
56 | + if ($this->session->refreshAccessToken($refreshAccessToken) !== true) { |
|
57 | 57 | throw new \RuntimeException(Message::ERROR_GET_REFRESH_TOKEN_BY_CODE); |
58 | 58 | } |
59 | 59 | return $this->session->getAccessToken(); |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @param array $options |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - public function getAuthorizeUrl(array $options = []) : string |
|
29 | + public function getAuthorizeUrl(array $options = [ ]) : string |
|
30 | 30 | { |
31 | 31 | return $this->baseSession->getAuthorizeUrl($options); |
32 | 32 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | * @param array $options |
10 | 10 | * @return string |
11 | 11 | */ |
12 | - public function getAuthorizeUrl(array $options = []): string; |
|
12 | + public function getAuthorizeUrl(array $options = [ ]): string; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @param string $authorizationCode |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | use \Xervice\DataProvider\DataProviderConfig; |
4 | 4 | |
5 | -$config[DataProviderConfig::DATA_PROVIDER_GENERATED_PATH] = dirname(__DIR__) . '/src/Domain/DataTransferObject'; |
|
5 | +$config[ DataProviderConfig::DATA_PROVIDER_GENERATED_PATH ] = dirname(__DIR__).'/src/Domain/DataTransferObject'; |
|
6 | 6 | |
7 | -$config[DataProviderConfig::DATA_PROVIDER_PATHS] = [ |
|
8 | - __DIR__ . '/xervice/schema' |
|
7 | +$config[ DataProviderConfig::DATA_PROVIDER_PATHS ] = [ |
|
8 | + __DIR__.'/xervice/schema' |
|
9 | 9 | ]; |
10 | 10 | |
11 | -$config[DataProviderConfig::DATA_PROVIDER_NAMESPACE] = 'SpotifyApiConnect\\Domain\\DataTransferObject'; |
|
12 | 11 | \ No newline at end of file |
12 | +$config[ DataProviderConfig::DATA_PROVIDER_NAMESPACE ] = 'SpotifyApiConnect\\Domain\\DataTransferObject'; |
|
13 | 13 | \ No newline at end of file |
@@ -34,17 +34,17 @@ |
||
34 | 34 | |
35 | 35 | $this->assertNotEmpty($redirectUrl, 'authorize url from spotify is empty'); |
36 | 36 | $parseRedirectUrl = parse_url($redirectUrl); |
37 | - $this->assertSame('accounts.spotify.com', $parseRedirectUrl['host']); |
|
38 | - $this->assertSame('/authorize', $parseRedirectUrl['path']); |
|
37 | + $this->assertSame('accounts.spotify.com', $parseRedirectUrl[ 'host' ]); |
|
38 | + $this->assertSame('/authorize', $parseRedirectUrl[ 'path' ]); |
|
39 | 39 | |
40 | - $this->assertNotEmpty($parseRedirectUrl['query']); |
|
40 | + $this->assertNotEmpty($parseRedirectUrl[ 'query' ]); |
|
41 | 41 | |
42 | - $info = []; |
|
43 | - parse_str($parseRedirectUrl['query'], $info); |
|
42 | + $info = [ ]; |
|
43 | + parse_str($parseRedirectUrl[ 'query' ], $info); |
|
44 | 44 | |
45 | - $this->assertSame('code', $info['response_type']); |
|
46 | - $this->assertSame('http://localhost/', $info['redirect_uri']); |
|
47 | - $this->assertTrue(isset($info['client_id'])); |
|
45 | + $this->assertSame('code', $info[ 'response_type' ]); |
|
46 | + $this->assertSame('http://localhost/', $info[ 'redirect_uri' ]); |
|
47 | + $this->assertTrue(isset($info[ 'client_id' ])); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function testRefreshAccessToken() |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require __DIR__ . '/../vendor/autoload.php'; |
|
3 | +require __DIR__.'/../vendor/autoload.php'; |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | public function testGetUserPlaylists(): void |
63 | 63 | { |
64 | 64 | $spotifyPlaylist = $this->spotifyWebApi->getUserPlaylistByName( |
65 | - static::spotifyInfo['user'], |
|
66 | - static::spotifyInfo['playlistName'] |
|
65 | + static::spotifyInfo[ 'user' ], |
|
66 | + static::spotifyInfo[ 'playlistName' ] |
|
67 | 67 | ); |
68 | - $this->assertSame(static::spotifyInfo['playlistId'], $spotifyPlaylist->getId()); |
|
68 | + $this->assertSame(static::spotifyInfo[ 'playlistId' ], $spotifyPlaylist->getId()); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | public function testGetUserPlaylistsNotFoundUser(): void |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | public function testGetUserPlaylistsNotFoundPlayList(): void |
78 | 78 | { |
79 | 79 | $this->expectException(PlaylistNotFound::class); |
80 | - $this->spotifyWebApi->getUserPlaylistByName(static::spotifyInfo['user'], 'uniTest-Not_FOUND-Playlist'); |
|
80 | + $this->spotifyWebApi->getUserPlaylistByName(static::spotifyInfo[ 'user' ], 'uniTest-Not_FOUND-Playlist'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | public function testGetPlaylist(): void |
84 | 84 | { |
85 | 85 | $spotifyPlayList = $this->spotifyWebApi->getPlaylist( |
86 | - static::spotifyInfo['playlistId'] |
|
86 | + static::spotifyInfo[ 'playlistId' ] |
|
87 | 87 | ); |
88 | - $this->assertSame(static::spotifyInfo['playlistId'], $spotifyPlayList->getId()); |
|
89 | - $this->assertSame(static::spotifyInfo['playlistName'], $spotifyPlayList->getName()); |
|
88 | + $this->assertSame(static::spotifyInfo[ 'playlistId' ], $spotifyPlayList->getId()); |
|
89 | + $this->assertSame(static::spotifyInfo[ 'playlistName' ], $spotifyPlayList->getName()); |
|
90 | 90 | $this->assertTrue($spotifyPlayList->getPublic()); |
91 | - $this->assertSame('U2', $spotifyPlayList->getTracks()->getItems()[0]->getTrack()->getArtists()[0]->getName()); |
|
91 | + $this->assertSame('U2', $spotifyPlayList->getTracks()->getItems()[ 0 ]->getTrack()->getArtists()[ 0 ]->getName()); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | public function testGetNoExistUserPlaylist(): void |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | { |
112 | 112 | $trackSearchRequestDataProvider = new TrackSearchRequestDataProvider(); |
113 | 113 | $trackSearchRequestDataProvider->setArtist( |
114 | - static::spotifySong['artist'] |
|
114 | + static::spotifySong[ 'artist' ] |
|
115 | 115 | ); |
116 | 116 | $trackSearchRequestDataProvider->setTrack( |
117 | - static::spotifySong['track'] |
|
117 | + static::spotifySong[ 'track' ] |
|
118 | 118 | ); |
119 | 119 | $searchResult = $this->spotifyWebApi->searchTrack($trackSearchRequestDataProvider); |
120 | 120 | |
121 | 121 | $this->assertGreaterThan(0, $searchResult->getItems()); |
122 | 122 | $this->assertSame( |
123 | - strtolower(static::spotifySong['track']), |
|
123 | + strtolower(static::spotifySong[ 'track' ]), |
|
124 | 124 | strtolower( |
125 | - $searchResult->getItems()[0]->getName() |
|
125 | + $searchResult->getItems()[ 0 ]->getName() |
|
126 | 126 | ) |
127 | 127 | ); |
128 | 128 | } |
@@ -144,27 +144,27 @@ discard block |
||
144 | 144 | public function testAddPlaylistTracks() |
145 | 145 | { |
146 | 146 | $addResult = $this->spotifyWebApi->addPlaylistTracks( |
147 | - static::spotifyInfo['playlistId'], |
|
147 | + static::spotifyInfo[ 'playlistId' ], |
|
148 | 148 | [ |
149 | - static::spotifySong['trackId'] |
|
149 | + static::spotifySong[ 'trackId' ] |
|
150 | 150 | ] |
151 | 151 | ); |
152 | 152 | $this->assertTrue($addResult); |
153 | 153 | |
154 | 154 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
155 | - static::spotifyInfo['playlistId'] |
|
155 | + static::spotifyInfo[ 'playlistId' ] |
|
156 | 156 | ); |
157 | 157 | |
158 | 158 | $this->assertNotEmpty($spotifyPlayList->getItems()); |
159 | 159 | $this->assertNotEmpty($spotifyPlayList->getTotal()); |
160 | - $this->assertSame(static::spotifySong['trackId'], $spotifyPlayList->getItems()[1]->getTrack()->getId()); |
|
160 | + $this->assertSame(static::spotifySong[ 'trackId' ], $spotifyPlayList->getItems()[ 1 ]->getTrack()->getId()); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | public function testAddPlaylistTracksNotExistTrackId() |
164 | 164 | { |
165 | 165 | try { |
166 | 166 | $this->spotifyWebApi->addPlaylistTracks( |
167 | - static::spotifyInfo['playlistId'], |
|
167 | + static::spotifyInfo[ 'playlistId' ], |
|
168 | 168 | [ |
169 | 169 | 'uniTest-Not_FOUND--ID' |
170 | 170 | ] |
@@ -183,24 +183,24 @@ discard block |
||
183 | 183 | public function testDeleteUserPlaylistTracks() |
184 | 184 | { |
185 | 185 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
186 | - static::spotifyInfo['playlistId'] |
|
186 | + static::spotifyInfo[ 'playlistId' ] |
|
187 | 187 | ); |
188 | 188 | |
189 | 189 | $this->assertCount(2, $spotifyPlayList->getItems()); |
190 | 190 | $this->assertSame(2, $spotifyPlayList->getTotal()); |
191 | 191 | |
192 | 192 | $deleteTrack = new DeleteTrackInfoDataProvider(); |
193 | - $deleteTrack->setId(static::spotifySong['trackId']); |
|
193 | + $deleteTrack->setId(static::spotifySong[ 'trackId' ]); |
|
194 | 194 | |
195 | 195 | $result = $this->spotifyWebApi->deletePlaylistTracks( |
196 | - static::spotifyInfo['playlistId'], |
|
197 | - [$deleteTrack] |
|
196 | + static::spotifyInfo[ 'playlistId' ], |
|
197 | + [ $deleteTrack ] |
|
198 | 198 | ); |
199 | 199 | |
200 | 200 | $this->assertTrue($result); |
201 | 201 | |
202 | 202 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
203 | - static::spotifyInfo['playlistId'] |
|
203 | + static::spotifyInfo[ 'playlistId' ] |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | $this->assertCount(1, $spotifyPlayList->getItems()); |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | $deleteTrack = new DeleteTrackInfoDataProvider(); |
214 | 214 | $deleteTrack->setId('uniTest-Not_FOUND--ID'); |
215 | 215 | $this->spotifyWebApi->deletePlaylistTracks( |
216 | - static::spotifyInfo['playlistId'], |
|
217 | - [$deleteTrack] |
|
216 | + static::spotifyInfo[ 'playlistId' ], |
|
217 | + [ $deleteTrack ] |
|
218 | 218 | ); |
219 | 219 | } catch (\SpotifyWebAPI\SpotifyWebAPIException $e) { |
220 | 220 | $this->assertSame( |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | { |
232 | 232 | $this->expectException(\RuntimeException::class); |
233 | 233 | $this->spotifyWebApi->deletePlaylistTracks( |
234 | - static::spotifyInfo['playlistId'], |
|
235 | - ['id' => 'hahaha'] |
|
234 | + static::spotifyInfo[ 'playlistId' ], |
|
235 | + [ 'id' => 'hahaha' ] |
|
236 | 236 | ); |
237 | 237 | } |
238 | 238 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param array $options |
38 | 38 | * @return bool |
39 | 39 | */ |
40 | - public function addPlaylistTracks($playlistId, array $tracks, array $options = []): bool |
|
40 | + public function addPlaylistTracks($playlistId, array $tracks, array $options = [ ]): bool |
|
41 | 41 | { |
42 | 42 | return $this->baseSpotifyWebAPI->addPlaylistTracks($playlistId, $tracks, $options); |
43 | 43 | } |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function deletePlaylistTracks(string $playlistId, array $tracksInfo): bool |
51 | 51 | { |
52 | - $tracksToDelete = []; |
|
52 | + $tracksToDelete = [ ]; |
|
53 | 53 | foreach ($tracksInfo as $deleteTrackInfoDataProvider) { |
54 | 54 | if (!$deleteTrackInfoDataProvider instanceof DeleteTrackInfoDataProvider) { |
55 | 55 | throw new \RuntimeException( |
56 | 56 | sprintf(Message::ERROR_DELETE_PLAYLIST_TRACKS, DeleteTrackInfoDataProvider::class) |
57 | 57 | ); |
58 | 58 | } |
59 | - $tracksToDelete[] = $deleteTrackInfoDataProvider->toArray(); |
|
59 | + $tracksToDelete[ ] = $deleteTrackInfoDataProvider->toArray(); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $this->baseSpotifyWebAPI->setReturnType(Request::RETURN_OBJECT); |
63 | - $delete = (bool)$this->baseSpotifyWebAPI->deletePlaylistTracks($playlistId, $tracksToDelete); |
|
63 | + $delete = (bool) $this->baseSpotifyWebAPI->deletePlaylistTracks($playlistId, $tracksToDelete); |
|
64 | 64 | $this->baseSpotifyWebAPI->setReturnType(Request::RETURN_ASSOC); |
65 | 65 | |
66 | 66 | return $delete; |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * @param array $options |
72 | 72 | * @return PlaylistDataProvider |
73 | 73 | */ |
74 | - public function getPlaylist(string $playlistId, array $options = []): PlaylistDataProvider |
|
74 | + public function getPlaylist(string $playlistId, array $options = [ ]): PlaylistDataProvider |
|
75 | 75 | { |
76 | - $jsonObjectResult = (array)$this->baseSpotifyWebAPI->getPlaylist($playlistId, $options); |
|
76 | + $jsonObjectResult = (array) $this->baseSpotifyWebAPI->getPlaylist($playlistId, $options); |
|
77 | 77 | |
78 | 78 | $playlistDataProvider = new PlaylistDataProvider(); |
79 | 79 | $playlistDataProvider->fromArray($jsonObjectResult); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @return PlaylistDataProvider |
89 | 89 | * @throws PlaylistNotFound |
90 | 90 | */ |
91 | - public function getUserPlaylistByName(string $userId, string $playlistName, array $options = []): PlaylistDataProvider |
|
91 | + public function getUserPlaylistByName(string $userId, string $playlistName, array $options = [ ]): PlaylistDataProvider |
|
92 | 92 | { |
93 | 93 | $userPlaylistsDataProvider = $this->getUserPlaylists($userId, $options); |
94 | 94 | $playlists = $userPlaylistsDataProvider->getItems(); |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * @param array $options |
107 | 107 | * @return PlaylistTracksDataProvider |
108 | 108 | */ |
109 | - public function getPlaylistTracks(string $playlistId, array $options = []): PlaylistTracksDataProvider |
|
109 | + public function getPlaylistTracks(string $playlistId, array $options = [ ]): PlaylistTracksDataProvider |
|
110 | 110 | { |
111 | - $jsonObjectResult = (array)$this->baseSpotifyWebAPI->getPlaylistTracks($playlistId, $options); |
|
111 | + $jsonObjectResult = (array) $this->baseSpotifyWebAPI->getPlaylistTracks($playlistId, $options); |
|
112 | 112 | |
113 | 113 | $playlistTracksDataProvider = new PlaylistTracksDataProvider(); |
114 | 114 | $playlistTracksDataProvider->fromArray($jsonObjectResult); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param array $options |
122 | 122 | * @return TracksSearchDataProvider |
123 | 123 | */ |
124 | - public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = []): TracksSearchDataProvider |
|
124 | + public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = [ ]): TracksSearchDataProvider |
|
125 | 125 | { |
126 | 126 | $jsonObjectResult = $this->search( |
127 | 127 | sprintf( |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | ); |
136 | 136 | |
137 | 137 | $tracksSearchDataProvider = new TracksSearchDataProvider(); |
138 | - $tracksSearchDataProvider->fromArray($jsonObjectResult[$trackSearchRequest->getResultType()]); |
|
138 | + $tracksSearchDataProvider->fromArray($jsonObjectResult[ $trackSearchRequest->getResultType() ]); |
|
139 | 139 | |
140 | 140 | return $tracksSearchDataProvider; |
141 | 141 | } |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | * @param array $options |
147 | 147 | * @return array |
148 | 148 | */ |
149 | - private function search(string $query, array $type, array $options = []): array |
|
149 | + private function search(string $query, array $type, array $options = [ ]): array |
|
150 | 150 | { |
151 | - return (array)$this->baseSpotifyWebAPI->search($query, $type, $options); |
|
151 | + return (array) $this->baseSpotifyWebAPI->search($query, $type, $options); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | * @param array $options |
157 | 157 | * @return UserPlaylistsDataProvider |
158 | 158 | */ |
159 | - private function getUserPlaylists(string $userId, array $options = []): UserPlaylistsDataProvider |
|
159 | + private function getUserPlaylists(string $userId, array $options = [ ]): UserPlaylistsDataProvider |
|
160 | 160 | { |
161 | - $userPlaylistInfo = (array)$this->baseSpotifyWebAPI->getUserPlaylists($userId, $options); |
|
161 | + $userPlaylistInfo = (array) $this->baseSpotifyWebAPI->getUserPlaylists($userId, $options); |
|
162 | 162 | |
163 | 163 | $userPlaylistsDataProvider = new UserPlaylistsDataProvider(); |
164 | 164 | $userPlaylistsDataProvider->fromArray($userPlaylistInfo); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param array $options |
17 | 17 | * @return bool |
18 | 18 | */ |
19 | - public function addPlaylistTracks($playlistId, array $tracks, array $options = []): bool; |
|
19 | + public function addPlaylistTracks($playlistId, array $tracks, array $options = [ ]): bool; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @param string $playlistId |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * @param array $options |
31 | 31 | * @return PlaylistDataProvider |
32 | 32 | */ |
33 | - public function getPlaylist(string $playlistId, array $options = []): PlaylistDataProvider; |
|
33 | + public function getPlaylist(string $playlistId, array $options = [ ]): PlaylistDataProvider; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @param $playlistId |
37 | 37 | * @param array $options |
38 | 38 | * @return object |
39 | 39 | */ |
40 | - public function getPlaylistTracks(string $playlistId, array $options = []); |
|
40 | + public function getPlaylistTracks(string $playlistId, array $options = [ ]); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @param string $userId |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @return PlaylistDataProvider |
47 | 47 | * @throws PlaylistNotFound |
48 | 48 | */ |
49 | - public function getUserPlaylistByName(string $userId, string $playlistName, array $options = []): PlaylistDataProvider; |
|
49 | + public function getUserPlaylistByName(string $userId, string $playlistName, array $options = [ ]): PlaylistDataProvider; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @param TrackSearchRequestDataProvider $trackSearchRequest |
53 | 53 | * @param array $options |
54 | 54 | * @return TracksSearchDataProvider |
55 | 55 | */ |
56 | - public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = []): TracksSearchDataProvider; |
|
56 | + public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = [ ]): TracksSearchDataProvider; |
|
57 | 57 | } |
58 | 58 | \ No newline at end of file |