Passed
Pull Request — master (#3)
by
unknown
01:53
created
src/TVDB.php 3 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -212,27 +212,27 @@
 block discarded – undo
212 212
     }
213 213
 
214 214
     /**
215
-	 * Retrieves Updates From Minutes Ago (max 7 days in the past)
216
-	 *
217
-	 * @param integer $from_minutes_ago
218
-	 * @throws Exceptions\TVDBUnauthorizedException
219
-	 * @throws Exceptions\TVDBNotFoundException
220
-	 *
221
-	 * @return UpdateCollection
222
-	 */
223
-	public static function getUpdates($from_minutes_ago) {
224
-		$from_time = time() - ($from_minutes_ago * 60);
225
-		$response = self::request([
226
-			'method'    => 'GET',
227
-			'url'       => self::apiURL('/updated/query?fromTime=' . $from_time),
228
-			'auth'      => true,
229
-			'name'      => 'get_episode'
230
-		]);
231
-
232
-		if(!$response->isSuccessful()) $response->throwException();
233
-
234
-		return new Updates($response->json()->data);
235
-	}
215
+     * Retrieves Updates From Minutes Ago (max 7 days in the past)
216
+     *
217
+     * @param integer $from_minutes_ago
218
+     * @throws Exceptions\TVDBUnauthorizedException
219
+     * @throws Exceptions\TVDBNotFoundException
220
+     *
221
+     * @return UpdateCollection
222
+     */
223
+    public static function getUpdates($from_minutes_ago) {
224
+        $from_time = time() - ($from_minutes_ago * 60);
225
+        $response = self::request([
226
+            'method'    => 'GET',
227
+            'url'       => self::apiURL('/updated/query?fromTime=' . $from_time),
228
+            'auth'      => true,
229
+            'name'      => 'get_episode'
230
+        ]);
231
+
232
+        if(!$response->isSuccessful()) $response->throwException();
233
+
234
+        return new Updates($response->json()->data);
235
+    }
236 236
     
237 237
     /**
238 238
      * Returns a valid TVDB token to use for authentication
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
         // Format search query
53 53
         $query = [];
54 54
 
55
-        if((is_array($options) && isset($options['title'])))
55
+        if ((is_array($options) && isset($options['title'])))
56 56
             $query['name'] = $options['title'];
57
-        else if(is_string($options))
57
+        else if (is_string($options))
58 58
             $query['name'] = $options;
59 59
 
60
-        if(is_array($options) && isset($options['imdbId'])) $query['imdbId'] = $options['imdbId'];
61
-        if(is_array($options) && isset($options['zap2itId'])) $query['zap2itId'] = $options['zap2itId'];
60
+        if (is_array($options) && isset($options['imdbId'])) $query['imdbId'] = $options['imdbId'];
61
+        if (is_array($options) && isset($options['zap2itId'])) $query['zap2itId'] = $options['zap2itId'];
62 62
 
63 63
         $response = self::request([
64 64
             'method'    => 'GET',
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
             'name'      => 'search_series'
69 69
         ]);
70 70
 
71
-        if(!$response->isSuccessful()) $response->throwException();
71
+        if (!$response->isSuccessful()) $response->throwException();
72 72
 
73 73
         $responseData = (isset($response->json()->data)) ? $response->json()->data : [];
74 74
         $series = [];
75 75
 
76
-        foreach($responseData as $seriesData)
76
+        foreach ($responseData as $seriesData)
77 77
             $series[] = new Series($seriesData);
78 78
 
79 79
         return $series;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             'name'      => 'get_series'
97 97
         ]);
98 98
 
99
-        if(!$response->isSuccessful()) $response->throwException();
99
+        if (!$response->isSuccessful()) $response->throwException();
100 100
 
101 101
         return new Series($response->json()->data);
102 102
     }
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
             'name'      => 'get_series_actors'
119 119
         ]);
120 120
 
121
-        if(!$response->isSuccessful()) $response->throwException();
121
+        if (!$response->isSuccessful()) $response->throwException();
122 122
 
123 123
         $returnData = [];
124 124
 
125
-        foreach($response->json()->data as $actorData)
125
+        foreach ($response->json()->data as $actorData)
126 126
             $returnData[] = new Actor($actorData);
127 127
 
128 128
         return $returnData;
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
             'name'      => 'get_series_images'
147 147
         ]);
148 148
 
149
-        if(!$response->isSuccessful()) $response->throwException();
149
+        if (!$response->isSuccessful()) $response->throwException();
150 150
 
151 151
         $returnData = [];
152 152
 
153
-        foreach($response->json()->data as $imageData)
153
+        foreach ($response->json()->data as $imageData)
154 154
             $returnData[] = [
155 155
                 'resolution'    => $imageData->resolution,
156 156
                 'image'         => self::IMAGE_URL_PREFIX . $imageData->fileName,
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
             'name'      => 'get_series_episodes'
180 180
         ]);
181 181
 
182
-        if(!$response->isSuccessful()) $response->throwException();
182
+        if (!$response->isSuccessful()) $response->throwException();
183 183
 
184 184
         $returnData = [];
185 185
 
186
-        foreach($response->json()->data as $episodeData)
186
+        foreach ($response->json()->data as $episodeData)
187 187
             $returnData[] = new Episode($episodeData);
188 188
 
189 189
         return new EpisodeCollection($page, $returnData);
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             'name'      => 'get_episode'
207 207
         ]);
208 208
 
209
-        if(!$response->isSuccessful()) $response->throwException();
209
+        if (!$response->isSuccessful()) $response->throwException();
210 210
 
211 211
         return new Episode($response->json()->data);
212 212
     }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 			'name'      => 'get_episode'
230 230
 		]);
231 231
 
232
-		if(!$response->isSuccessful()) $response->throwException();
232
+		if (!$response->isSuccessful()) $response->throwException();
233 233
 
234 234
 		return new Updates($response->json()->data);
235 235
 	}
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      */
244 244
     public static function getToken() {
245 245
         // Try to to refresh the cached token if there is one
246
-        if(Cache::has(self::TOKEN_CACHE_KEY)) {
246
+        if (Cache::has(self::TOKEN_CACHE_KEY)) {
247 247
             return Cache::get(self::TOKEN_CACHE_KEY);
248 248
         }
249 249
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         ]);
264 264
 
265 265
         // Login may have failed
266
-        if(!$loginResponse->isSuccessful()) $loginResponse->throwException();
266
+        if (!$loginResponse->isSuccessful()) $loginResponse->throwException();
267 267
 
268 268
         // Successfully logged in
269 269
         $token = $loginResponse->json()->token;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         $url = $options['url'];
287 287
 
288 288
         // Add URL query params
289
-        if(isset($options['query']))
289
+        if (isset($options['query']))
290 290
             $url .= '?' . http_build_query($options['query']);
291 291
 
292 292
         // Initialize handle
@@ -298,13 +298,13 @@  discard block
 block discarded – undo
298 298
         // Add authentication header
299 299
         $usedToken = null;
300 300
 
301
-        if(isset($options['auth']) && $options['auth'] === true) {
301
+        if (isset($options['auth']) && $options['auth'] === true) {
302 302
             $usedToken = self::getToken();
303 303
             $requestHeaders[] = 'Authorization: ' . 'Bearer ' . $usedToken;
304 304
         }
305 305
 
306 306
         // Add postfields
307
-        if(isset($options['postfields'])) {
307
+        if (isset($options['postfields'])) {
308 308
             curl_setopt($curlHandle, CURLOPT_POSTFIELDS, json_encode($options['postfields']));
309 309
         }
310 310
 
Please login to merge, or discard this patch.
Braces   +50 added lines, -24 removed lines patch added patch discarded remove patch
@@ -52,13 +52,18 @@  discard block
 block discarded – undo
52 52
         // Format search query
53 53
         $query = [];
54 54
 
55
-        if((is_array($options) && isset($options['title'])))
56
-            $query['name'] = $options['title'];
57
-        else if(is_string($options))
58
-            $query['name'] = $options;
55
+        if((is_array($options) && isset($options['title']))) {
56
+                    $query['name'] = $options['title'];
57
+        } else if(is_string($options)) {
58
+                    $query['name'] = $options;
59
+        }
59 60
 
60
-        if(is_array($options) && isset($options['imdbId'])) $query['imdbId'] = $options['imdbId'];
61
-        if(is_array($options) && isset($options['zap2itId'])) $query['zap2itId'] = $options['zap2itId'];
61
+        if(is_array($options) && isset($options['imdbId'])) {
62
+            $query['imdbId'] = $options['imdbId'];
63
+        }
64
+        if(is_array($options) && isset($options['zap2itId'])) {
65
+            $query['zap2itId'] = $options['zap2itId'];
66
+        }
62 67
 
63 68
         $response = self::request([
64 69
             'method'    => 'GET',
@@ -68,13 +73,16 @@  discard block
 block discarded – undo
68 73
             'name'      => 'search_series'
69 74
         ]);
70 75
 
71
-        if(!$response->isSuccessful()) $response->throwException();
76
+        if(!$response->isSuccessful()) {
77
+            $response->throwException();
78
+        }
72 79
 
73 80
         $responseData = (isset($response->json()->data)) ? $response->json()->data : [];
74 81
         $series = [];
75 82
 
76
-        foreach($responseData as $seriesData)
77
-            $series[] = new Series($seriesData);
83
+        foreach($responseData as $seriesData) {
84
+                    $series[] = new Series($seriesData);
85
+        }
78 86
 
79 87
         return $series;
80 88
     }
@@ -96,7 +104,9 @@  discard block
 block discarded – undo
96 104
             'name'      => 'get_series'
97 105
         ]);
98 106
 
99
-        if(!$response->isSuccessful()) $response->throwException();
107
+        if(!$response->isSuccessful()) {
108
+            $response->throwException();
109
+        }
100 110
 
101 111
         return new Series($response->json()->data);
102 112
     }
@@ -118,12 +128,15 @@  discard block
 block discarded – undo
118 128
             'name'      => 'get_series_actors'
119 129
         ]);
120 130
 
121
-        if(!$response->isSuccessful()) $response->throwException();
131
+        if(!$response->isSuccessful()) {
132
+            $response->throwException();
133
+        }
122 134
 
123 135
         $returnData = [];
124 136
 
125
-        foreach($response->json()->data as $actorData)
126
-            $returnData[] = new Actor($actorData);
137
+        foreach($response->json()->data as $actorData) {
138
+                    $returnData[] = new Actor($actorData);
139
+        }
127 140
 
128 141
         return $returnData;
129 142
     }
@@ -146,16 +159,19 @@  discard block
 block discarded – undo
146 159
             'name'      => 'get_series_images'
147 160
         ]);
148 161
 
149
-        if(!$response->isSuccessful()) $response->throwException();
162
+        if(!$response->isSuccessful()) {
163
+            $response->throwException();
164
+        }
150 165
 
151 166
         $returnData = [];
152 167
 
153
-        foreach($response->json()->data as $imageData)
154
-            $returnData[] = [
168
+        foreach($response->json()->data as $imageData) {
169
+                    $returnData[] = [
155 170
                 'resolution'    => $imageData->resolution,
156 171
                 'image'         => self::IMAGE_URL_PREFIX . $imageData->fileName,
157 172
                 'image_thumb'   => self::IMAGE_URL_PREFIX . $imageData->thumbnail
158 173
             ];
174
+        }
159 175
 
160 176
         return $returnData;
161 177
     }
@@ -179,12 +195,15 @@  discard block
 block discarded – undo
179 195
             'name'      => 'get_series_episodes'
180 196
         ]);
181 197
 
182
-        if(!$response->isSuccessful()) $response->throwException();
198
+        if(!$response->isSuccessful()) {
199
+            $response->throwException();
200
+        }
183 201
 
184 202
         $returnData = [];
185 203
 
186
-        foreach($response->json()->data as $episodeData)
187
-            $returnData[] = new Episode($episodeData);
204
+        foreach($response->json()->data as $episodeData) {
205
+                    $returnData[] = new Episode($episodeData);
206
+        }
188 207
 
189 208
         return new EpisodeCollection($page, $returnData);
190 209
     }
@@ -206,7 +225,9 @@  discard block
 block discarded – undo
206 225
             'name'      => 'get_episode'
207 226
         ]);
208 227
 
209
-        if(!$response->isSuccessful()) $response->throwException();
228
+        if(!$response->isSuccessful()) {
229
+            $response->throwException();
230
+        }
210 231
 
211 232
         return new Episode($response->json()->data);
212 233
     }
@@ -229,7 +250,9 @@  discard block
 block discarded – undo
229 250
 			'name'      => 'get_episode'
230 251
 		]);
231 252
 
232
-		if(!$response->isSuccessful()) $response->throwException();
253
+		if(!$response->isSuccessful()) {
254
+		    $response->throwException();
255
+		}
233 256
 
234 257
 		return new Updates($response->json()->data);
235 258
 	}
@@ -263,7 +286,9 @@  discard block
 block discarded – undo
263 286
         ]);
264 287
 
265 288
         // Login may have failed
266
-        if(!$loginResponse->isSuccessful()) $loginResponse->throwException();
289
+        if(!$loginResponse->isSuccessful()) {
290
+            $loginResponse->throwException();
291
+        }
267 292
 
268 293
         // Successfully logged in
269 294
         $token = $loginResponse->json()->token;
@@ -286,8 +311,9 @@  discard block
 block discarded – undo
286 311
         $url = $options['url'];
287 312
 
288 313
         // Add URL query params
289
-        if(isset($options['query']))
290
-            $url .= '?' . http_build_query($options['query']);
314
+        if(isset($options['query'])) {
315
+                    $url .= '?' . http_build_query($options['query']);
316
+        }
291 317
 
292 318
         // Initialize handle
293 319
         $curlHandle = curl_init($url);
Please login to merge, or discard this patch.
src/Updates.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
6 6
 
7 7
 class Updates
8 8
 {
9
-	public $updates = [];
9
+    public $updates = [];
10 10
 
11
-	public function __construct( $data )
12
-	{
13
-		foreach ( $data as $show_update ) {
14
-			$this->updates[ $show_update->id ] = Carbon::parse( $show_update->lastUpdated );
15
-		}
16
-	}
11
+    public function __construct( $data )
12
+    {
13
+        foreach ( $data as $show_update ) {
14
+            $this->updates[ $show_update->id ] = Carbon::parse( $show_update->lastUpdated );
15
+        }
16
+    }
17 17
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
8 8
 {
9 9
 	public $updates = [];
10 10
 
11
-	public function __construct( $data )
11
+	public function __construct($data)
12 12
 	{
13
-		foreach ( $data as $show_update ) {
14
-			$this->updates[ $show_update->id ] = Carbon::parse( $show_update->lastUpdated );
13
+		foreach ($data as $show_update) {
14
+			$this->updates[$show_update->id] = Carbon::parse($show_update->lastUpdated);
15 15
 		}
16 16
 	}
17 17
 }
Please login to merge, or discard this patch.