@@ -42,9 +42,11 @@ discard block |
||
| 42 | 42 | * @return bool |
| 43 | 43 | */ |
| 44 | 44 | public function isSuccessful() { |
| 45 | - if($this->info['http_code'] === 200) |
|
| 46 | - return true; |
|
| 47 | - else return false; |
|
| 45 | + if($this->info['http_code'] === 200) { |
|
| 46 | + return true; |
|
| 47 | + } else { |
|
| 48 | + return false; |
|
| 49 | + } |
|
| 48 | 50 | } |
| 49 | 51 | |
| 50 | 52 | /** |
@@ -58,8 +60,7 @@ discard block |
||
| 58 | 60 | if($this->info['http_code'] === 401) { |
| 59 | 61 | if($this->name == 'login') { |
| 60 | 62 | throw new TVDBUnauthorizedException('401: Unable to retrieve a TVDB token with the given details. Check your config.'); |
| 61 | - } |
|
| 62 | - else { |
|
| 63 | + } else { |
|
| 63 | 64 | throw new TVDBUnauthorizedException( |
| 64 | 65 | '401: Unauthorized request to ' . $this->info['url'] . '. ' . |
| 65 | 66 | (($this->usedToken === null) ? '(no TVDB token was found)' : '(however a TVDB token was found)') |
@@ -70,14 +71,11 @@ discard block |
||
| 70 | 71 | else if($this->info['http_code'] === 404) { |
| 71 | 72 | if($this->name == 'get_series') { |
| 72 | 73 | throw new TVDBNotFoundException('404: Unable to find the series - ' . $this->info['url']); |
| 73 | - } |
|
| 74 | - else if($this->name == 'get_series_actors') { |
|
| 74 | + } else if($this->name == 'get_series_actors') { |
|
| 75 | 75 | throw new TVDBNotFoundException('404: Unable to find the actors - ' . $this->info['url']); |
| 76 | - } |
|
| 77 | - else if($this->name == 'get_series_episodes') { |
|
| 76 | + } else if($this->name == 'get_series_episodes') { |
|
| 78 | 77 | throw new TVDBNotFoundException('404: Unable to find the episodes - ' . $this->info['url']); |
| 79 | - } |
|
| 80 | - else if($this->name == 'get_episode') { |
|
| 78 | + } else if($this->name == 'get_episode') { |
|
| 81 | 79 | throw new TVDBNotFoundException('404: Unable to find the episode - ' . $this->info['url']); |
| 82 | 80 | } |
| 83 | 81 | // Generic 404 exception |
@@ -24,10 +24,11 @@ |
||
| 24 | 24 | $this->imdbId = (strlen($data->imdbId)) ? $data->imdbId : null; |
| 25 | 25 | $this->name = $data->episodeName; |
| 26 | 26 | |
| 27 | - if($data->filename) |
|
| 28 | - $this->image = TVDB::IMAGE_URL_PREFIX . $data->filename; |
|
| 29 | - else |
|
| 30 | - $this->image = null; |
|
| 27 | + if($data->filename) { |
|
| 28 | + $this->image = TVDB::IMAGE_URL_PREFIX . $data->filename; |
|
| 29 | + } else { |
|
| 30 | + $this->image = null; |
|
| 31 | + } |
|
| 31 | 32 | |
| 32 | 33 | $this->season = $data->airedSeason; |
| 33 | 34 | $this->number = $data->airedEpisodeNumber; |
@@ -52,13 +52,18 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |