Passed
Pull Request — master (#5)
by Rafal
02:30
created
src/Domain/Model/Config.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      */
13 13
     public function getClientId(): string
14 14
     {
15
-        $clientId = (string)getenv('CLIENT_ID');
15
+        $clientId = (string) getenv('CLIENT_ID');
16 16
         if (empty($clientId)) {
17 17
             throw new RuntimeException(
18 18
                 sprintf(Message::ERROR_GET_ENV_VARIABLE, 'CLIENT_ID')
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function getClientSecret(): string
29 29
     {
30
-        $clientSecret = (string)getenv('CLIENT_SECRET');
30
+        $clientSecret = (string) getenv('CLIENT_SECRET');
31 31
         if (empty($clientSecret)) {
32 32
             throw new RuntimeException(
33 33
                 sprintf(Message::ERROR_GET_ENV_VARIABLE, 'CLIENT_SECRET')
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function getRedirectUri(): string
44 44
     {
45
-        $redirectUri = (string)getenv('REDIRECT_URI');
45
+        $redirectUri = (string) getenv('REDIRECT_URI');
46 46
         if (empty($redirectUri)) {
47 47
             throw new RuntimeException(
48 48
                 sprintf(Message::ERROR_GET_ENV_VARIABLE, 'REDIRECT_URI')
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function getSpotifyUsername(): string
59 59
     {
60
-        $spotifyUsername = (string)getenv('SPOTIFY_USERNAME');
60
+        $spotifyUsername = (string) getenv('SPOTIFY_USERNAME');
61 61
         if (empty($spotifyUsername)) {
62 62
             throw new RuntimeException(
63 63
                 sprintf(Message::ERROR_GET_ENV_VARIABLE, 'SPOTIFY_USERNAME')
Please login to merge, or discard this patch.
src/Application/SpotifyWebApiInterface.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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,26 +30,26 @@  discard block
 block discarded – undo
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 $playlistName
44 44
      * @param array $options
45 45
      * @return PlaylistDataProvider
46 46
      */
47
-    public function getUserPlaylistByName(string $playlistName, array $options = []): PlaylistDataProvider;
47
+    public function getUserPlaylistByName(string $playlistName, array $options = [ ]): PlaylistDataProvider;
48 48
 
49 49
     /**
50 50
      * @param TrackSearchRequestDataProvider $trackSearchRequest
51 51
      * @param array $options
52 52
      * @return TracksSearchDataProvider
53 53
      */
54
-    public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = []): TracksSearchDataProvider;
54
+    public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = [ ]): TracksSearchDataProvider;
55 55
 }
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
src/Application/SpotifyWebApiPhp/SpotifyWebApi.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @param array $options
51 51
      * @return bool
52 52
      */
53
-    public function addPlaylistTracks($playlistId, array $tracks, array $options = []): bool
53
+    public function addPlaylistTracks($playlistId, array $tracks, array $options = [ ]): bool
54 54
     {
55 55
         return $this->baseSpotifyWebAPI->addPlaylistTracks($playlistId, $tracks, $options);
56 56
     }
@@ -62,18 +62,18 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function deletePlaylistTracks(string $playlistId, array $tracksInfo): bool
64 64
     {
65
-        $tracksToDelete = [];
65
+        $tracksToDelete = [ ];
66 66
         foreach ($tracksInfo as $deleteTrackInfoDataProvider) {
67 67
             if (!$deleteTrackInfoDataProvider instanceof DeleteTrackInfoDataProvider) {
68 68
                 throw new RuntimeException(
69 69
                     sprintf(Message::ERROR_DELETE_PLAYLIST_TRACKS, DeleteTrackInfoDataProvider::class)
70 70
                 );
71 71
             }
72
-            $tracksToDelete[] = $deleteTrackInfoDataProvider->toArray();
72
+            $tracksToDelete[ ] = $deleteTrackInfoDataProvider->toArray();
73 73
         }
74 74
 
75 75
         $this->baseSpotifyWebAPI->setReturnType(Request::RETURN_OBJECT);
76
-        $delete = (bool)$this->baseSpotifyWebAPI->deletePlaylistTracks($playlistId, $tracksToDelete);
76
+        $delete = (bool) $this->baseSpotifyWebAPI->deletePlaylistTracks($playlistId, $tracksToDelete);
77 77
         $this->baseSpotifyWebAPI->setReturnType(Request::RETURN_ASSOC);
78 78
 
79 79
         return $delete;
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      * @param array $options
85 85
      * @return PlaylistDataProvider
86 86
      */
87
-    public function getPlaylist(string $playlistId, array $options = []): PlaylistDataProvider
87
+    public function getPlaylist(string $playlistId, array $options = [ ]): PlaylistDataProvider
88 88
     {
89
-        $jsonObjectResult = (array)$this->baseSpotifyWebAPI->getPlaylist($playlistId, $options);
89
+        $jsonObjectResult = (array) $this->baseSpotifyWebAPI->getPlaylist($playlistId, $options);
90 90
 
91 91
         $playlistDataProvider = new PlaylistDataProvider();
92 92
         $playlistDataProvider->fromArray($jsonObjectResult);
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      * @return PlaylistDataProvider
101 101
      * @throws PlaylistNotFound
102 102
      */
103
-    public function getUserPlaylistByName(string $playlistName, array $options = []): PlaylistDataProvider
103
+    public function getUserPlaylistByName(string $playlistName, array $options = [ ]): PlaylistDataProvider
104 104
     {
105 105
         $userPlaylistsDataProvider = $this->getUserPlaylists($options);
106 106
         $playlists = $userPlaylistsDataProvider->getItems();
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
      * @param array $options
119 119
      * @return PlaylistTracksDataProvider
120 120
      */
121
-    public function getPlaylistTracks(string $playlistId, array $options = []): PlaylistTracksDataProvider
121
+    public function getPlaylistTracks(string $playlistId, array $options = [ ]): PlaylistTracksDataProvider
122 122
     {
123
-        $jsonObjectResult = (array)$this->baseSpotifyWebAPI->getPlaylistTracks($playlistId, $options);
123
+        $jsonObjectResult = (array) $this->baseSpotifyWebAPI->getPlaylistTracks($playlistId, $options);
124 124
 
125 125
         $playlistTracksDataProvider = new PlaylistTracksDataProvider();
126 126
         $playlistTracksDataProvider->fromArray($jsonObjectResult);
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      * @param array $options
134 134
      * @return TracksSearchDataProvider
135 135
      */
136
-    public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = []): TracksSearchDataProvider
136
+    public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = [ ]): TracksSearchDataProvider
137 137
     {
138 138
         $jsonObjectResult = $this->search(
139 139
             sprintf(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         );
148 148
 
149 149
         $tracksSearchDataProvider = new TracksSearchDataProvider();
150
-        $tracksSearchDataProvider->fromArray($jsonObjectResult[$trackSearchRequest->getResultType()]);
150
+        $tracksSearchDataProvider->fromArray($jsonObjectResult[ $trackSearchRequest->getResultType() ]);
151 151
 
152 152
         return $tracksSearchDataProvider;
153 153
     }
@@ -158,18 +158,18 @@  discard block
 block discarded – undo
158 158
      * @param array $options
159 159
      * @return array
160 160
      */
161
-    private function search(string $query, array $type, array $options = []): array
161
+    private function search(string $query, array $type, array $options = [ ]): array
162 162
     {
163
-        return (array)$this->baseSpotifyWebAPI->search($query, $type, $options);
163
+        return (array) $this->baseSpotifyWebAPI->search($query, $type, $options);
164 164
     }
165 165
 
166 166
     /**
167 167
      * @param array $options
168 168
      * @return UserPlaylistsDataProvider
169 169
      */
170
-    private function getUserPlaylists(array $options = []): UserPlaylistsDataProvider
170
+    private function getUserPlaylists(array $options = [ ]): UserPlaylistsDataProvider
171 171
     {
172
-        $userPlaylistInfo = (array)$this->baseSpotifyWebAPI->getUserPlaylists($this->spotifyUsername, $options);
172
+        $userPlaylistInfo = (array) $this->baseSpotifyWebAPI->getUserPlaylists($this->spotifyUsername, $options);
173 173
 
174 174
         $userPlaylistsDataProvider = new UserPlaylistsDataProvider();
175 175
         $userPlaylistsDataProvider->fromArray($userPlaylistInfo);
Please login to merge, or discard this patch.
test/Unit/Domain/Model/ConfigTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $this->config = new Config();
28 28
         foreach ($this->env as $envName => $envValue) {
29
-            $this->env[$envName] = getenv($envName);
29
+            $this->env[ $envName ] = getenv($envName);
30 30
             putenv($envName.'=0');
31 31
         }
32 32
         parent::setUp();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $envValue = 'UnitSecret';
46 46
         putenv('CLIENT_SECRET='.$envValue);
47
-        $this->assertSame($envValue,$this->config->getClientSecret());
47
+        $this->assertSame($envValue, $this->config->getClientSecret());
48 48
     }
49 49
 
50 50
     public function testGetClientSecretException()
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $envValue = 'UnitId';
59 59
         putenv('CLIENT_ID='.$envValue);
60
-        $this->assertSame($envValue,$this->config->getClientId());
60
+        $this->assertSame($envValue, $this->config->getClientId());
61 61
     }
62 62
 
63 63
     public function testGetClientIdException()
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $envValue = 'UnitRedirectUri';
72 72
         putenv('REDIRECT_URI='.$envValue);
73
-        $this->assertSame($envValue,$this->config->getRedirectUri());
73
+        $this->assertSame($envValue, $this->config->getRedirectUri());
74 74
     }
75 75
 
76 76
     public function testGetRedirectUriException()
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     {
84 84
         $envValue = 'UnitSpotifyUserName';
85 85
         putenv('SPOTIFY_USERNAME='.$envValue);
86
-        $this->assertSame($envValue,$this->config->getSpotifyUsername());
86
+        $this->assertSame($envValue, $this->config->getSpotifyUsername());
87 87
     }
88 88
 
89 89
     public function testGetSpotifyUsernameException()
Please login to merge, or discard this patch.
test/Integration/Application/SpotifyWebApiPhp/SpotifyWebApiTest.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
         $spotifyApiConnectFactory = new SpotifyApiConnectFactory();
38 38
         $spotifyApiAuth = $spotifyApiConnectFactory->createSpotifyApiAuth();
39 39
         $accessToken = $spotifyApiAuth->getAccessByRefreshToken(getenv('REFRESH_TOKEN'));
40
-        $this->spotifyWebApi =  $spotifyApiConnectFactory->createSpotifyWebApi($accessToken);
40
+        $this->spotifyWebApi = $spotifyApiConnectFactory->createSpotifyWebApi($accessToken);
41 41
     }
42 42
 
43 43
 
44 44
     public function testGetUserPlaylists(): void
45 45
     {
46 46
         $spotifyPlaylist = $this->spotifyWebApi->getUserPlaylistByName(
47
-            static::spotifyInfo['playlistName']
47
+            static::spotifyInfo[ 'playlistName' ]
48 48
         );
49
-        $this->assertSame(static::spotifyInfo['playlistId'], $spotifyPlaylist->getId());
49
+        $this->assertSame(static::spotifyInfo[ 'playlistId' ], $spotifyPlaylist->getId());
50 50
     }
51 51
 
52 52
     public function testGetUserPlaylistsNotFoundPlayList(): void
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
     public function testGetPlaylist(): void
59 59
     {
60 60
         $spotifyPlayList = $this->spotifyWebApi->getPlaylist(
61
-            static::spotifyInfo['playlistId']
61
+            static::spotifyInfo[ 'playlistId' ]
62 62
         );
63
-        $this->assertSame(static::spotifyInfo['playlistId'], $spotifyPlayList->getId());
64
-        $this->assertSame(static::spotifyInfo['playlistName'], $spotifyPlayList->getName());
63
+        $this->assertSame(static::spotifyInfo[ 'playlistId' ], $spotifyPlayList->getId());
64
+        $this->assertSame(static::spotifyInfo[ 'playlistName' ], $spotifyPlayList->getName());
65 65
         $this->assertTrue($spotifyPlayList->getPublic());
66
-        $this->assertSame('U2', $spotifyPlayList->getTracks()->getItems()[0]->getTrack()->getArtists()[0]->getName());
66
+        $this->assertSame('U2', $spotifyPlayList->getTracks()->getItems()[ 0 ]->getTrack()->getArtists()[ 0 ]->getName());
67 67
     }
68 68
 
69 69
     public function testGetNoExistUserPlaylist(): void
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
     {
87 87
         $trackSearchRequestDataProvider = new TrackSearchRequestDataProvider();
88 88
         $trackSearchRequestDataProvider->setArtist(
89
-            static::spotifySong['artist']
89
+            static::spotifySong[ 'artist' ]
90 90
         );
91 91
         $trackSearchRequestDataProvider->setTrack(
92
-            static::spotifySong['track']
92
+            static::spotifySong[ 'track' ]
93 93
         );
94 94
         $searchResult = $this->spotifyWebApi->searchTrack($trackSearchRequestDataProvider);
95 95
 
96 96
         $this->assertGreaterThan(0, $searchResult->getItems());
97 97
         $this->assertSame(
98
-            strtolower(static::spotifySong['track']),
98
+            strtolower(static::spotifySong[ 'track' ]),
99 99
             strtolower(
100
-                $searchResult->getItems()[0]->getName()
100
+                $searchResult->getItems()[ 0 ]->getName()
101 101
             )
102 102
         );
103 103
     }
@@ -119,27 +119,27 @@  discard block
 block discarded – undo
119 119
     public function testAddPlaylistTracks()
120 120
     {
121 121
         $addResult = $this->spotifyWebApi->addPlaylistTracks(
122
-            static::spotifyInfo['playlistId'],
122
+            static::spotifyInfo[ 'playlistId' ],
123 123
             [
124
-                static::spotifySong['trackId']
124
+                static::spotifySong[ 'trackId' ]
125 125
             ]
126 126
         );
127 127
         $this->assertTrue($addResult);
128 128
 
129 129
         $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks(
130
-            static::spotifyInfo['playlistId']
130
+            static::spotifyInfo[ 'playlistId' ]
131 131
         );
132 132
 
133 133
         $this->assertNotEmpty($spotifyPlayList->getItems());
134 134
         $this->assertNotEmpty($spotifyPlayList->getTotal());
135
-        $this->assertSame(static::spotifySong['trackId'], $spotifyPlayList->getItems()[1]->getTrack()->getId());
135
+        $this->assertSame(static::spotifySong[ 'trackId' ], $spotifyPlayList->getItems()[ 1 ]->getTrack()->getId());
136 136
     }
137 137
 
138 138
     public function testAddPlaylistTracksNotExistTrackId()
139 139
     {
140 140
         try {
141 141
             $this->spotifyWebApi->addPlaylistTracks(
142
-                static::spotifyInfo['playlistId'],
142
+                static::spotifyInfo[ 'playlistId' ],
143 143
                 [
144 144
                     'uniTest-Not_FOUND--ID'
145 145
                 ]
@@ -158,24 +158,24 @@  discard block
 block discarded – undo
158 158
     public function testDeleteUserPlaylistTracks()
159 159
     {
160 160
         $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks(
161
-            static::spotifyInfo['playlistId']
161
+            static::spotifyInfo[ 'playlistId' ]
162 162
         );
163 163
 
164 164
         $this->assertCount(2, $spotifyPlayList->getItems());
165 165
         $this->assertSame(2, $spotifyPlayList->getTotal());
166 166
 
167 167
         $deleteTrack = new DeleteTrackInfoDataProvider();
168
-        $deleteTrack->setId(static::spotifySong['trackId']);
168
+        $deleteTrack->setId(static::spotifySong[ 'trackId' ]);
169 169
 
170 170
         $result = $this->spotifyWebApi->deletePlaylistTracks(
171
-            static::spotifyInfo['playlistId'],
172
-            [$deleteTrack]
171
+            static::spotifyInfo[ 'playlistId' ],
172
+            [ $deleteTrack ]
173 173
         );
174 174
 
175 175
         $this->assertTrue($result);
176 176
 
177 177
         $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks(
178
-            static::spotifyInfo['playlistId']
178
+            static::spotifyInfo[ 'playlistId' ]
179 179
         );
180 180
 
181 181
         $this->assertCount(1, $spotifyPlayList->getItems());
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
             $deleteTrack = new DeleteTrackInfoDataProvider();
189 189
             $deleteTrack->setId('uniTest-Not_FOUND--ID');
190 190
             $this->spotifyWebApi->deletePlaylistTracks(
191
-                static::spotifyInfo['playlistId'],
192
-                [$deleteTrack]
191
+                static::spotifyInfo[ 'playlistId' ],
192
+                [ $deleteTrack ]
193 193
             );
194 194
         } catch (\SpotifyWebAPI\SpotifyWebAPIException $e) {
195 195
             $this->assertSame(
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
     {
207 207
         $this->expectException(\RuntimeException::class);
208 208
         $this->spotifyWebApi->deletePlaylistTracks(
209
-            static::spotifyInfo['playlistId'],
210
-            ['id' => 'hahaha']
209
+            static::spotifyInfo[ 'playlistId' ],
210
+            [ 'id' => 'hahaha' ]
211 211
         );
212 212
     }
213 213
 }
Please login to merge, or discard this patch.