@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of the Tmdb package. |
| 4 | 4 | * |
@@ -29,7 +29,8 @@ |
||
| 29 | 29 | protected function searchItemGenerator(array $results, string $class) |
| 30 | 30 | { |
| 31 | 31 | $this->logger->debug('Starting search item generator', array('results' => $results, 'class' => $class)); |
| 32 | - foreach ($results as $result) { |
|
| 32 | + foreach ($results as $result) |
|
| 33 | + { |
|
| 33 | 34 | $element = new $class($this->tmdb, $result); |
| 34 | 35 | |
| 35 | 36 | yield $element; |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of the Tmdb package. |
| 4 | 4 | * |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of the Tmdb package. |
| 4 | 4 | * |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of the Tmdb package. |
| 4 | 4 | * |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of the Tmdb package. |
| 4 | 4 | * |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of the Tmdb package. |
| 4 | 4 | * |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of the Tmdb package. |
| 4 | 4 | * |
@@ -63,10 +63,12 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | private function searchItem(string $item, string $query, array $options, string $result_class) : \Generator |
| 65 | 65 | { |
| 66 | - try { |
|
| 66 | + try |
|
| 67 | + { |
|
| 67 | 68 | $this->logger->debug('Starting search item', array('item' => $item, 'query' => $query, 'options' => $options, 'result_class' => $result_class)); |
| 68 | 69 | $query = trim($query); |
| 69 | - if (empty($query)) { |
|
| 70 | + if (empty($query)) |
|
| 71 | + { |
|
| 70 | 72 | $this->logger->error('Query param cannot be empty', array('item' => $item, 'query' => $query, 'options' => $options, 'result_class' => $result_class)); |
| 71 | 73 | throw new IncorrectParamException; |
| 72 | 74 | } |
@@ -79,7 +81,9 @@ discard block |
||
| 79 | 81 | $this->total_results = (int) $response->total_results; |
| 80 | 82 | |
| 81 | 83 | return $this->searchItemGenerator($response->results, $result_class); |
| 82 | - } catch (TmdbException $ex) { |
|
| 84 | + } |
|
| 85 | + catch (TmdbException $ex) |
|
| 86 | + { |
|
| 83 | 87 | throw $ex; |
| 84 | 88 | } |
| 85 | 89 | } |
@@ -93,10 +97,13 @@ discard block |
||
| 93 | 97 | */ |
| 94 | 98 | public function movie(string $query, array $options = array()) : \Generator |
| 95 | 99 | { |
| 96 | - try { |
|
| 100 | + try |
|
| 101 | + { |
|
| 97 | 102 | $this->logger->debug('Starting search movie', array('query' => $query, 'options' => $options)); |
| 98 | 103 | return $this->searchItem('movie', $query, $options, Results\Movie::class); |
| 99 | - } catch (TmdbException $ex) { |
|
| 104 | + } |
|
| 105 | + catch (TmdbException $ex) |
|
| 106 | + { |
|
| 100 | 107 | throw $ex; |
| 101 | 108 | } |
| 102 | 109 | } |
@@ -110,10 +117,13 @@ discard block |
||
| 110 | 117 | */ |
| 111 | 118 | public function tvshow(string $query, array $options = array()) : \Generator |
| 112 | 119 | { |
| 113 | - try { |
|
| 120 | + try |
|
| 121 | + { |
|
| 114 | 122 | $this->logger->debug('Starting search tv show', array('query' => $query, 'options' => $options)); |
| 115 | 123 | return $this->searchItem('tv', $query, $options, Results\TVShow::class); |
| 116 | - } catch (TmdbException $ex) { |
|
| 124 | + } |
|
| 125 | + catch (TmdbException $ex) |
|
| 126 | + { |
|
| 117 | 127 | throw $ex; |
| 118 | 128 | } |
| 119 | 129 | } |
@@ -127,10 +137,13 @@ discard block |
||
| 127 | 137 | */ |
| 128 | 138 | public function collection(string $query, array $options = array()) : \Generator |
| 129 | 139 | { |
| 130 | - try { |
|
| 140 | + try |
|
| 141 | + { |
|
| 131 | 142 | $this->logger->debug('Starting search collection', array('query' => $query, 'options' => $options)); |
| 132 | 143 | return $this->searchItem('collection', $query, $options, Results\Collection::class); |
| 133 | - } catch (TmdbException $ex) { |
|
| 144 | + } |
|
| 145 | + catch (TmdbException $ex) |
|
| 146 | + { |
|
| 134 | 147 | throw $ex; |
| 135 | 148 | } |
| 136 | 149 | } |
@@ -144,10 +157,13 @@ discard block |
||
| 144 | 157 | */ |
| 145 | 158 | public function people(string $query, array $options = array()) : \Generator |
| 146 | 159 | { |
| 147 | - try { |
|
| 160 | + try |
|
| 161 | + { |
|
| 148 | 162 | $this->logger->debug('Starting search people', array('query' => $query, 'options' => $options)); |
| 149 | 163 | return $this->searchItem('person', $query, $options, Results\People::class); |
| 150 | - } catch (TmdbException $ex) { |
|
| 164 | + } |
|
| 165 | + catch (TmdbException $ex) |
|
| 166 | + { |
|
| 151 | 167 | throw $ex; |
| 152 | 168 | } |
| 153 | 169 | } |
@@ -161,10 +177,13 @@ discard block |
||
| 161 | 177 | */ |
| 162 | 178 | public function company(string $query, array $options = array()) : \Generator |
| 163 | 179 | { |
| 164 | - try { |
|
| 180 | + try |
|
| 181 | + { |
|
| 165 | 182 | $this->logger->debug('Starting search company', array('query' => $query, 'options' => $options)); |
| 166 | 183 | return $this->searchItem('company', $query, $options, Results\Company::class); |
| 167 | - } catch (TmdbException $ex) { |
|
| 184 | + } |
|
| 185 | + catch (TmdbException $ex) |
|
| 186 | + { |
|
| 168 | 187 | throw $ex; |
| 169 | 188 | } |
| 170 | 189 | } |
@@ -167,15 +167,15 @@ |
||
| 167 | 167 | { |
| 168 | 168 | $res = new \stdClass(); |
| 169 | 169 | switch ($method) { |
| 170 | - case 'GET': |
|
| 170 | + case 'GET': |
|
| 171 | 171 | $res = $this->http_request->getResponse($url); |
| 172 | - break; |
|
| 173 | - case 'POST': |
|
| 172 | + break; |
|
| 173 | + case 'POST': |
|
| 174 | 174 | $res = $this->http_request->postResponse($url, [], $form_params); |
| 175 | - break; |
|
| 176 | - case 'DELETE': |
|
| 175 | + break; |
|
| 176 | + case 'DELETE': |
|
| 177 | 177 | $res = $this->http_request->deleteResponse($url); |
| 178 | - break; |
|
| 178 | + break; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | if (empty($res->getBody())) { |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * This file is part of the Tmdb package. |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function checkOptions(array $options) : array |
| 242 | 242 | { |
| 243 | - $params = []; |
|
| 243 | + $params = []; |
|
| 244 | 244 | // Check options |
| 245 | 245 | foreach ($options as $key => $value) { |
| 246 | 246 | switch ($key) { |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | default: |
| 314 | 314 | throw new IncorrectParamException; |
| 315 | 315 | } |
| 316 | - return 'created_at.'.$direction; |
|
| 316 | + return 'created_at.' . $direction; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
@@ -166,7 +166,8 @@ discard block |
||
| 166 | 166 | protected function sendRequest(string $method, string $url, array $form_params = array()) : ?\stdClass |
| 167 | 167 | { |
| 168 | 168 | $res = new \stdClass(); |
| 169 | - switch ($method) { |
|
| 169 | + switch ($method) |
|
| 170 | + { |
|
| 170 | 171 | case 'GET': |
| 171 | 172 | $res = $this->http_request->getResponse($url); |
| 172 | 173 | break; |
@@ -178,12 +179,14 @@ discard block |
||
| 178 | 179 | break; |
| 179 | 180 | } |
| 180 | 181 | |
| 181 | - if (empty($res->getBody())) { |
|
| 182 | + if (empty($res->getBody())) |
|
| 183 | + { |
|
| 182 | 184 | $this->logger->error('Request Body empty', array('method' => $method, 'url' => $url, 'form_params' => $form_params)); |
| 183 | 185 | throw new ServerErrorException(); |
| 184 | 186 | } |
| 185 | 187 | $response = json_decode($res->getBody()); |
| 186 | - if (empty($response)) { |
|
| 188 | + if (empty($response)) |
|
| 189 | + { |
|
| 187 | 190 | $this->logger->error('Request Body can not be decode', array('method' => $method, 'url' => $url, 'form_params' => $form_params)); |
| 188 | 191 | throw new ServerErrorException(); |
| 189 | 192 | } |
@@ -220,14 +223,18 @@ discard block |
||
| 220 | 223 | */ |
| 221 | 224 | public function getConfiguration() : \stdClass |
| 222 | 225 | { |
| 223 | - try { |
|
| 226 | + try |
|
| 227 | + { |
|
| 224 | 228 | $this->logger->debug('Start getting configuration'); |
| 225 | - if (is_null($this->configuration)) { |
|
| 229 | + if (is_null($this->configuration)) |
|
| 230 | + { |
|
| 226 | 231 | $this->logger->debug('No configuration found, sending HTTP request to get it'); |
| 227 | 232 | $this->configuration = $this->getRequest('configuration'); |
| 228 | 233 | } |
| 229 | 234 | return $this->configuration; |
| 230 | - } catch (TmdbException $ex) { |
|
| 235 | + } |
|
| 236 | + catch (TmdbException $ex) |
|
| 237 | + { |
|
| 231 | 238 | throw $ex; |
| 232 | 239 | } |
| 233 | 240 | } |
@@ -242,8 +249,10 @@ discard block |
||
| 242 | 249 | { |
| 243 | 250 | $params = []; |
| 244 | 251 | // Check options |
| 245 | - foreach ($options as $key => $value) { |
|
| 246 | - switch ($key) { |
|
| 252 | + foreach ($options as $key => $value) |
|
| 253 | + { |
|
| 254 | + switch ($key) |
|
| 255 | + { |
|
| 247 | 256 | case 'year': |
| 248 | 257 | $params[$key] = $this->checkYear($value); |
| 249 | 258 | break; |
@@ -291,7 +300,8 @@ discard block |
||
| 291 | 300 | private function checkLanguage(string $language) : string |
| 292 | 301 | { |
| 293 | 302 | $check = preg_match("#([a-z]{2})-([A-Z]{2})#", $language); |
| 294 | - if ($check === 0 || $check === false) { |
|
| 303 | + if ($check === 0 || $check === false) |
|
| 304 | + { |
|
| 295 | 305 | $this->logger->error('Incorrect language param option', array('language' => $language)); |
| 296 | 306 | throw new IncorrectParamException; |
| 297 | 307 | } |
@@ -306,7 +316,8 @@ discard block |
||
| 306 | 316 | */ |
| 307 | 317 | private function checkSort(string $direction) : string |
| 308 | 318 | { |
| 309 | - switch ($direction) { |
|
| 319 | + switch ($direction) |
|
| 320 | + { |
|
| 310 | 321 | case 'asc': |
| 311 | 322 | case 'desc': |
| 312 | 323 | break; |
@@ -332,7 +343,8 @@ discard block |
||
| 332 | 343 | */ |
| 333 | 344 | public function __get(string $name) : string |
| 334 | 345 | { |
| 335 | - switch ($name) { |
|
| 346 | + switch ($name) |
|
| 347 | + { |
|
| 336 | 348 | case 'url': |
| 337 | 349 | return $this->$name; |
| 338 | 350 | default: |