@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | parent::setUp(); |
| 44 | 44 | $spotifyApiConnectFactory = new SpotifyApiConnectFactory(); |
| 45 | 45 | $spotifyApiAuth = $spotifyApiConnectFactory->createSpotifyApiAuth(); |
| 46 | - $accessToken = $spotifyApiAuth->getAccessByRefreshToken($_ENV['REFRESH_TOKEN']); |
|
| 46 | + $accessToken = $spotifyApiAuth->getAccessByRefreshToken($_ENV[ 'REFRESH_TOKEN' ]); |
|
| 47 | 47 | $this->spotifyWebApi = $spotifyApiConnectFactory->createSpotifyWebApi($accessToken); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | public function testGetUserPlaylists(): void |
| 52 | 52 | { |
| 53 | 53 | $spotifyPlaylist = $this->spotifyWebApi->getUserPlaylistByName( |
| 54 | - static::spotifyInfo['playlistName'] |
|
| 54 | + static::spotifyInfo[ 'playlistName' ] |
|
| 55 | 55 | ); |
| 56 | - $this->assertSame(static::spotifyInfo['playlistId'], $spotifyPlaylist->getId()); |
|
| 56 | + $this->assertSame(static::spotifyInfo[ 'playlistId' ], $spotifyPlaylist->getId()); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function testGetUserPlaylistsNotFoundPlayList(): void |
@@ -65,29 +65,29 @@ discard block |
||
| 65 | 65 | public function testAddPlaylistTracks() |
| 66 | 66 | { |
| 67 | 67 | $addResult = $this->spotifyWebApi->addPlaylistTracks( |
| 68 | - static::spotifyInfo['playlistId'], |
|
| 68 | + static::spotifyInfo[ 'playlistId' ], |
|
| 69 | 69 | [ |
| 70 | - static::spotifySongInit['trackId'] |
|
| 70 | + static::spotifySongInit[ 'trackId' ] |
|
| 71 | 71 | ] |
| 72 | 72 | ); |
| 73 | 73 | $this->assertTrue($addResult); |
| 74 | 74 | |
| 75 | 75 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 76 | - static::spotifyInfo['playlistId'] |
|
| 76 | + static::spotifyInfo[ 'playlistId' ] |
|
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | $this->assertNotEmpty($spotifyPlayList->getItems()); |
| 80 | 80 | $this->assertNotEmpty($spotifyPlayList->getTotal()); |
| 81 | - $this->assertSame(static::spotifySongInit['trackId'], $spotifyPlayList->getItems()[0]->getTrack()->getId()); |
|
| 82 | - $this->assertSame(static::spotifySongInit['artist'], $spotifyPlayList->getItems()[0]->getTrack()->getArtists()[0]->getName()); |
|
| 83 | - $this->assertSame(static::spotifySongInit['track'], $spotifyPlayList->getItems()[0]->getTrack()->getName()); |
|
| 81 | + $this->assertSame(static::spotifySongInit[ 'trackId' ], $spotifyPlayList->getItems()[ 0 ]->getTrack()->getId()); |
|
| 82 | + $this->assertSame(static::spotifySongInit[ 'artist' ], $spotifyPlayList->getItems()[ 0 ]->getTrack()->getArtists()[ 0 ]->getName()); |
|
| 83 | + $this->assertSame(static::spotifySongInit[ 'track' ], $spotifyPlayList->getItems()[ 0 ]->getTrack()->getName()); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function testAddPlaylistTracksNotExistTrackId() |
| 87 | 87 | { |
| 88 | 88 | try { |
| 89 | 89 | $this->spotifyWebApi->addPlaylistTracks( |
| 90 | - static::spotifyInfo['playlistId'], |
|
| 90 | + static::spotifyInfo[ 'playlistId' ], |
|
| 91 | 91 | [ |
| 92 | 92 | 'uniTest-Not_FOUND--ID' |
| 93 | 93 | ] |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | public function testGetPlaylist(): void |
| 107 | 107 | { |
| 108 | 108 | $spotifyPlayList = $this->spotifyWebApi->getPlaylist( |
| 109 | - static::spotifyInfo['playlistId'] |
|
| 109 | + static::spotifyInfo[ 'playlistId' ] |
|
| 110 | 110 | ); |
| 111 | - $this->assertSame(static::spotifyInfo['playlistId'], $spotifyPlayList->getId()); |
|
| 112 | - $this->assertSame(static::spotifyInfo['playlistName'], $spotifyPlayList->getName()); |
|
| 111 | + $this->assertSame(static::spotifyInfo[ 'playlistId' ], $spotifyPlayList->getId()); |
|
| 112 | + $this->assertSame(static::spotifyInfo[ 'playlistName' ], $spotifyPlayList->getName()); |
|
| 113 | 113 | $this->assertTrue($spotifyPlayList->getPublic()); |
| 114 | - $this->assertSame(self::spotifySongInit['artist'], $spotifyPlayList->getTracks()->getItems()[0]->getTrack()->getArtists()[0]->getName()); |
|
| 114 | + $this->assertSame(self::spotifySongInit[ 'artist' ], $spotifyPlayList->getTracks()->getItems()[ 0 ]->getTrack()->getArtists()[ 0 ]->getName()); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function testGetNoExistUserPlaylist(): void |
@@ -134,18 +134,18 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $trackSearchRequestDataProvider = new TrackSearchRequestDataProvider(); |
| 136 | 136 | $trackSearchRequestDataProvider->setArtist( |
| 137 | - static::spotifySong['artist'] |
|
| 137 | + static::spotifySong[ 'artist' ] |
|
| 138 | 138 | ); |
| 139 | 139 | $trackSearchRequestDataProvider->setTrack( |
| 140 | - static::spotifySong['track'] |
|
| 140 | + static::spotifySong[ 'track' ] |
|
| 141 | 141 | ); |
| 142 | 142 | $searchResult = $this->spotifyWebApi->searchTrack($trackSearchRequestDataProvider); |
| 143 | 143 | |
| 144 | 144 | $this->assertGreaterThan(0, $searchResult->getItems()); |
| 145 | 145 | $this->assertSame( |
| 146 | - strtolower(static::spotifySong['track']), |
|
| 146 | + strtolower(static::spotifySong[ 'track' ]), |
|
| 147 | 147 | strtolower( |
| 148 | - $searchResult->getItems()[0]->getName() |
|
| 148 | + $searchResult->getItems()[ 0 ]->getName() |
|
| 149 | 149 | ) |
| 150 | 150 | ); |
| 151 | 151 | } |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | public function testDeleteUserPlaylistTracks() |
| 168 | 168 | { |
| 169 | 169 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 170 | - static::spotifyInfo['playlistId'] |
|
| 170 | + static::spotifyInfo[ 'playlistId' ] |
|
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | 173 | $this->assertCount(1, $spotifyPlayList->getItems()); |
| 174 | 174 | $this->assertSame(1, $spotifyPlayList->getTotal()); |
| 175 | 175 | |
| 176 | 176 | $deleteTrack = new DeleteTrackInfoDataProvider(); |
| 177 | - $deleteTrack->setId(static::spotifySong['trackId']); |
|
| 177 | + $deleteTrack->setId(static::spotifySong[ 'trackId' ]); |
|
| 178 | 178 | |
| 179 | 179 | $result = $this->spotifyWebApi->deletePlaylistTracks( |
| 180 | - static::spotifyInfo['playlistId'], |
|
| 181 | - [$deleteTrack] |
|
| 180 | + static::spotifyInfo[ 'playlistId' ], |
|
| 181 | + [ $deleteTrack ] |
|
| 182 | 182 | ); |
| 183 | 183 | |
| 184 | 184 | $this->assertTrue($result); |
| 185 | 185 | |
| 186 | 186 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 187 | - static::spotifyInfo['playlistId'] |
|
| 187 | + static::spotifyInfo[ 'playlistId' ] |
|
| 188 | 188 | ); |
| 189 | 189 | |
| 190 | 190 | $this->assertCount(1, $spotifyPlayList->getItems()); |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | $deleteTrack = new DeleteTrackInfoDataProvider(); |
| 198 | 198 | $deleteTrack->setId('uniTest-Not_FOUND--ID'); |
| 199 | 199 | $this->spotifyWebApi->deletePlaylistTracks( |
| 200 | - static::spotifyInfo['playlistId'], |
|
| 201 | - [$deleteTrack] |
|
| 200 | + static::spotifyInfo[ 'playlistId' ], |
|
| 201 | + [ $deleteTrack ] |
|
| 202 | 202 | ); |
| 203 | 203 | } catch (\SpotifyWebAPI\SpotifyWebAPIException $e) { |
| 204 | 204 | $this->assertSame( |
@@ -215,40 +215,40 @@ discard block |
||
| 215 | 215 | { |
| 216 | 216 | $this->expectException(\RuntimeException::class); |
| 217 | 217 | $this->spotifyWebApi->deletePlaylistTracks( |
| 218 | - static::spotifyInfo['playlistId'], |
|
| 219 | - ['id' => 'hahaha'] |
|
| 218 | + static::spotifyInfo[ 'playlistId' ], |
|
| 219 | + [ 'id' => 'hahaha' ] |
|
| 220 | 220 | ); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | public function testDeleteAllSongsInPlaylist() |
| 224 | 224 | { |
| 225 | - $songsIds = include __DIR__ . '/songs_ids.php'; |
|
| 225 | + $songsIds = include __DIR__.'/songs_ids.php'; |
|
| 226 | 226 | $addResult = $this->spotifyWebApi->addPlaylistTracks( |
| 227 | - static::spotifyInfo['playlistId'], |
|
| 227 | + static::spotifyInfo[ 'playlistId' ], |
|
| 228 | 228 | $songsIds |
| 229 | 229 | ); |
| 230 | 230 | $this->assertTrue($addResult); |
| 231 | 231 | |
| 232 | 232 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 233 | - static::spotifyInfo['playlistId'] |
|
| 233 | + static::spotifyInfo[ 'playlistId' ] |
|
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | 236 | $this->assertGreaterThan(210, $spotifyPlayList->getItems()); |
| 237 | 237 | |
| 238 | - $deleteTracks = []; |
|
| 238 | + $deleteTracks = [ ]; |
|
| 239 | 239 | foreach ($spotifyPlayList->getItems() as $item) { |
| 240 | 240 | $deleteTrack = new DeleteTrackInfoDataProvider(); |
| 241 | 241 | $deleteTrack->setId($item->getTrack()->getId()); |
| 242 | - $deleteTracks[] = $deleteTrack; |
|
| 242 | + $deleteTracks[ ] = $deleteTrack; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | $this->spotifyWebApi->deletePlaylistTracks( |
| 246 | - static::spotifyInfo['playlistId'], |
|
| 246 | + static::spotifyInfo[ 'playlistId' ], |
|
| 247 | 247 | $deleteTracks |
| 248 | 248 | ); |
| 249 | 249 | |
| 250 | 250 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 251 | - static::spotifyInfo['playlistId'] |
|
| 251 | + static::spotifyInfo[ 'playlistId' ] |
|
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | 254 | $this->assertCount(0, $spotifyPlayList->getItems()); |
@@ -52,15 +52,15 @@ discard block |
||
| 52 | 52 | * @param array $options |
| 53 | 53 | * @return bool |
| 54 | 54 | */ |
| 55 | - public function addPlaylistTracks($playlistId, array $tracks, array $options = []): bool |
|
| 55 | + public function addPlaylistTracks($playlistId, array $tracks, array $options = [ ]): bool |
|
| 56 | 56 | { |
| 57 | - $trackIds = []; |
|
| 57 | + $trackIds = [ ]; |
|
| 58 | 58 | $returnAddPlaylistResult = false; |
| 59 | 59 | foreach ($tracks as $trackId) { |
| 60 | - $trackIds[] = $trackId; |
|
| 60 | + $trackIds[ ] = $trackId; |
|
| 61 | 61 | if (count($trackIds) % 100 === 0) { |
| 62 | 62 | $returnAddPlaylistResult = $this->baseSpotifyWebAPI->addPlaylistTracks($playlistId, $trackIds, $options); |
| 63 | - $trackIds = []; |
|
| 63 | + $trackIds = [ ]; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function deletePlaylistTracks(string $playlistId, array $tracksInfo): bool |
| 80 | 80 | { |
| 81 | - $tracksToDelete = []; |
|
| 81 | + $tracksToDelete = [ ]; |
|
| 82 | 82 | $delete = false; |
| 83 | 83 | $this->baseSpotifyWebAPI->setReturnType(Request::RETURN_OBJECT); |
| 84 | 84 | |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | sprintf(Message::ERROR_DELETE_PLAYLIST_TRACKS, DeleteTrackInfoDataProvider::class) |
| 89 | 89 | ); |
| 90 | 90 | } |
| 91 | - $tracksToDelete[] = $deleteTrackInfoDataProvider->toArray(); |
|
| 91 | + $tracksToDelete[ ] = $deleteTrackInfoDataProvider->toArray(); |
|
| 92 | 92 | if (count($tracksToDelete) % 100 === 0) { |
| 93 | - $delete = (bool)$this->baseSpotifyWebAPI->deletePlaylistTracks($playlistId, ['tracks' => $tracksToDelete]); |
|
| 94 | - $tracksToDelete = []; |
|
| 93 | + $delete = (bool) $this->baseSpotifyWebAPI->deletePlaylistTracks($playlistId, [ 'tracks' => $tracksToDelete ]); |
|
| 94 | + $tracksToDelete = [ ]; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if(!empty($tracksToDelete)) { |
|
| 99 | - $delete = (bool)$this->baseSpotifyWebAPI->deletePlaylistTracks($playlistId, ['tracks' => $tracksToDelete]); |
|
| 98 | + if (!empty($tracksToDelete)) { |
|
| 99 | + $delete = (bool) $this->baseSpotifyWebAPI->deletePlaylistTracks($playlistId, [ 'tracks' => $tracksToDelete ]); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $this->baseSpotifyWebAPI->setReturnType(Request::RETURN_ASSOC); |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | * @param array $options |
| 110 | 110 | * @return PlaylistDataProvider |
| 111 | 111 | */ |
| 112 | - public function getPlaylist(string $playlistId, array $options = []): PlaylistDataProvider |
|
| 112 | + public function getPlaylist(string $playlistId, array $options = [ ]): PlaylistDataProvider |
|
| 113 | 113 | { |
| 114 | - $jsonObjectResult = (array)$this->baseSpotifyWebAPI->getPlaylist($playlistId, $options); |
|
| 114 | + $jsonObjectResult = (array) $this->baseSpotifyWebAPI->getPlaylist($playlistId, $options); |
|
| 115 | 115 | |
| 116 | 116 | $playlistDataProvider = new PlaylistDataProvider(); |
| 117 | 117 | $playlistDataProvider->fromArray($jsonObjectResult); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @return PlaylistDataProvider |
| 126 | 126 | * @throws PlaylistNotFound |
| 127 | 127 | */ |
| 128 | - public function getUserPlaylistByName(string $playlistName, array $options = []): PlaylistDataProvider |
|
| 128 | + public function getUserPlaylistByName(string $playlistName, array $options = [ ]): PlaylistDataProvider |
|
| 129 | 129 | { |
| 130 | 130 | $userPlaylistsDataProvider = $this->getUserPlaylists($options); |
| 131 | 131 | $playlists = $userPlaylistsDataProvider->getItems(); |
@@ -143,23 +143,23 @@ discard block |
||
| 143 | 143 | * @param array $options |
| 144 | 144 | * @return PlaylistTracksDataProvider |
| 145 | 145 | */ |
| 146 | - public function getPlaylistTracks(string $playlistId, array $options = []): PlaylistTracksDataProvider |
|
| 146 | + public function getPlaylistTracks(string $playlistId, array $options = [ ]): PlaylistTracksDataProvider |
|
| 147 | 147 | { |
| 148 | 148 | $offset = 0; |
| 149 | - $items = []; |
|
| 149 | + $items = [ ]; |
|
| 150 | 150 | |
| 151 | 151 | do { |
| 152 | - $response = (object)$this->baseSpotifyWebAPI->getPlaylistTracks($playlistId, [ |
|
| 152 | + $response = (object) $this->baseSpotifyWebAPI->getPlaylistTracks($playlistId, [ |
|
| 153 | 153 | 'offset' => $offset, |
| 154 | 154 | ]); |
| 155 | 155 | $offset += 100; |
| 156 | - $items[] = $response->items; |
|
| 156 | + $items[ ] = $response->items; |
|
| 157 | 157 | $hasNext = $response->next; |
| 158 | 158 | } while ($hasNext); |
| 159 | - $response->items = array_merge([], ...$items); |
|
| 159 | + $response->items = array_merge([ ], ...$items); |
|
| 160 | 160 | |
| 161 | 161 | $playlistTracksDataProvider = new PlaylistTracksDataProvider(); |
| 162 | - $playlistTracksDataProvider->fromArray((array)$response); |
|
| 162 | + $playlistTracksDataProvider->fromArray((array) $response); |
|
| 163 | 163 | |
| 164 | 164 | return $playlistTracksDataProvider; |
| 165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param array $options |
| 170 | 170 | * @return TracksSearchDataProvider |
| 171 | 171 | */ |
| 172 | - public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = []): TracksSearchDataProvider |
|
| 172 | + public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = [ ]): TracksSearchDataProvider |
|
| 173 | 173 | { |
| 174 | 174 | $jsonObjectResult = $this->search( |
| 175 | 175 | sprintf( |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | 185 | $tracksSearchDataProvider = new TracksSearchDataProvider(); |
| 186 | - $tracksSearchDataProvider->fromArray($jsonObjectResult[$trackSearchRequest->getResultType()]); |
|
| 186 | + $tracksSearchDataProvider->fromArray($jsonObjectResult[ $trackSearchRequest->getResultType() ]); |
|
| 187 | 187 | |
| 188 | 188 | return $tracksSearchDataProvider; |
| 189 | 189 | } |
@@ -194,18 +194,18 @@ discard block |
||
| 194 | 194 | * @param array $options |
| 195 | 195 | * @return array |
| 196 | 196 | */ |
| 197 | - private function search(string $query, array $type, array $options = []): array |
|
| 197 | + private function search(string $query, array $type, array $options = [ ]): array |
|
| 198 | 198 | { |
| 199 | - return (array)$this->baseSpotifyWebAPI->search($query, $type, $options); |
|
| 199 | + return (array) $this->baseSpotifyWebAPI->search($query, $type, $options); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
| 203 | 203 | * @param array $options |
| 204 | 204 | * @return UserPlaylistsDataProvider |
| 205 | 205 | */ |
| 206 | - private function getUserPlaylists(array $options = []): UserPlaylistsDataProvider |
|
| 206 | + private function getUserPlaylists(array $options = [ ]): UserPlaylistsDataProvider |
|
| 207 | 207 | { |
| 208 | - $userPlaylistInfo = (array)$this->baseSpotifyWebAPI->getUserPlaylists($this->spotifyUsername, $options); |
|
| 208 | + $userPlaylistInfo = (array) $this->baseSpotifyWebAPI->getUserPlaylists($this->spotifyUsername, $options); |
|
| 209 | 209 | |
| 210 | 210 | $userPlaylistsDataProvider = new UserPlaylistsDataProvider(); |
| 211 | 211 | $userPlaylistsDataProvider->fromArray($userPlaylistInfo); |