@@ -18,7 +18,6 @@ |
||
18 | 18 | use VfacTmdb\Exceptions\IncorrectParamException; |
19 | 19 | use VfacTmdb\Interfaces\TmdbInterface; |
20 | 20 | use VfacTmdb\Interfaces\AuthInterface; |
21 | - |
|
22 | 21 | use VfacTmdb\Exceptions\InvalidResponseException; |
23 | 22 | |
24 | 23 | /** |
@@ -121,11 +121,11 @@ |
||
121 | 121 | public function __get(string $name) |
122 | 122 | { |
123 | 123 | switch ($name) { |
124 | - case 'request_token': |
|
124 | + case 'request_token': |
|
125 | 125 | case 'session_id': |
126 | 126 | return $this->$name; |
127 | - default: |
|
127 | + default: |
|
128 | 128 | throw new NotFoundException(); |
129 | - } |
|
129 | + } |
|
130 | 130 | } |
131 | 131 | } |
@@ -1,4 +1,4 @@ discard block |
||
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 | * |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * Session Id |
54 | 54 | * @var string |
55 | 55 | */ |
56 | - private $session_id = null; |
|
56 | + private $session_id = null; |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Constructor |
@@ -74,8 +74,10 @@ discard block |
||
74 | 74 | public function connect(string $request_token, ?string $redirect_url = null) : bool |
75 | 75 | { |
76 | 76 | $url = "https://www.themoviedb.org/authenticate/$request_token"; |
77 | - if (!is_null($redirect_url)) { |
|
78 | - if (!filter_var($redirect_url, FILTER_VALIDATE_URL)) { |
|
77 | + if (!is_null($redirect_url)) |
|
78 | + { |
|
79 | + if (!filter_var($redirect_url, FILTER_VALIDATE_URL)) |
|
80 | + { |
|
79 | 81 | throw new IncorrectParamException('Invalid redirect Url'); |
80 | 82 | } |
81 | 83 | $url .= "?redirect_to=$redirect_url"; |
@@ -92,7 +94,8 @@ discard block |
||
92 | 94 | { |
93 | 95 | $data = $this->tmdb->getRequest('authentication/token/new', []); |
94 | 96 | |
95 | - if (!isset($data->success) || $data->success != 'true' || !isset($data->request_token)) { |
|
97 | + if (!isset($data->success) || $data->success != 'true' || !isset($data->request_token)) |
|
98 | + { |
|
96 | 99 | throw new InvalidResponseException("Getting request token failed"); |
97 | 100 | } |
98 | 101 | $this->request_token = $data->request_token; |
@@ -110,7 +113,8 @@ discard block |
||
110 | 113 | { |
111 | 114 | $data = $this->tmdb->getRequest('authentication/session/new', ['request_token' => $request_token]); |
112 | 115 | |
113 | - if (!isset($data->success) || $data->success != 'true' || !isset($data->session_id)) { |
|
116 | + if (!isset($data->success) || $data->success != 'true' || !isset($data->session_id)) |
|
117 | + { |
|
114 | 118 | throw new InvalidResponseException("Creating session failed"); |
115 | 119 | } |
116 | 120 | $this->session_id = $data->session_id; |
@@ -124,7 +128,8 @@ discard block |
||
124 | 128 | */ |
125 | 129 | public function __get(string $name) |
126 | 130 | { |
127 | - switch ($name) { |
|
131 | + switch ($name) |
|
132 | + { |
|
128 | 133 | case 'request_token': |
129 | 134 | case 'session_id': |
130 | 135 | return $this->$name; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Get production compagnies |
185 | - * @return \Generator|Company |
|
185 | + * @return \Generator |
|
186 | 186 | */ |
187 | 187 | public function getProductionCompanies() : \Generator |
188 | 188 | { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Get production countries |
204 | - * @return \Generator|\stdClass |
|
204 | + * @return \Generator |
|
205 | 205 | */ |
206 | 206 | public function getProductionCountries() : \Generator |
207 | 207 | { |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | /** |
220 | 220 | * Get image backdrops list |
221 | - * @return \Generator|Results\Image |
|
221 | + * @return \Generator |
|
222 | 222 | */ |
223 | 223 | public function getBackdrops() : \Generator |
224 | 224 | { |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | /** |
234 | 234 | * Get image posters list |
235 | - * @return \Generator|Results\Image |
|
235 | + * @return \Generator |
|
236 | 236 | */ |
237 | 237 | public function getPosters() : \Generator |
238 | 238 | { |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Get similar movies from current movie |
249 | - * @return \Generator|Results\Movie |
|
249 | + * @return \Generator |
|
250 | 250 | */ |
251 | 251 | public function getSimilar() : \Generator |
252 | 252 | { |
@@ -49,7 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function getGenres() : array |
51 | 51 | { |
52 | - if (isset($this->data->genres)) { |
|
52 | + if (isset($this->data->genres)) |
|
53 | + { |
|
53 | 54 | return $this->data->genres; |
54 | 55 | } |
55 | 56 | return []; |
@@ -61,7 +62,8 @@ discard block |
||
61 | 62 | */ |
62 | 63 | public function getTitle() : string |
63 | 64 | { |
64 | - if (isset($this->data->title)) { |
|
65 | + if (isset($this->data->title)) |
|
66 | + { |
|
65 | 67 | return $this->data->title; |
66 | 68 | } |
67 | 69 | return ''; |
@@ -73,7 +75,8 @@ discard block |
||
73 | 75 | */ |
74 | 76 | public function getOverview() : string |
75 | 77 | { |
76 | - if (isset($this->data->overview)) { |
|
78 | + if (isset($this->data->overview)) |
|
79 | + { |
|
77 | 80 | return $this->data->overview; |
78 | 81 | } |
79 | 82 | return ''; |
@@ -85,7 +88,8 @@ discard block |
||
85 | 88 | */ |
86 | 89 | public function getReleaseDate() : string |
87 | 90 | { |
88 | - if (isset($this->data->release_date)) { |
|
91 | + if (isset($this->data->release_date)) |
|
92 | + { |
|
89 | 93 | return $this->data->release_date; |
90 | 94 | } |
91 | 95 | return ''; |
@@ -97,7 +101,8 @@ discard block |
||
97 | 101 | */ |
98 | 102 | public function getOriginalTitle() : string |
99 | 103 | { |
100 | - if (isset($this->data->original_title)) { |
|
104 | + if (isset($this->data->original_title)) |
|
105 | + { |
|
101 | 106 | return $this->data->original_title; |
102 | 107 | } |
103 | 108 | return ''; |
@@ -109,7 +114,8 @@ discard block |
||
109 | 114 | */ |
110 | 115 | public function getNote() : float |
111 | 116 | { |
112 | - if (isset($this->data->vote_average)) { |
|
117 | + if (isset($this->data->vote_average)) |
|
118 | + { |
|
113 | 119 | return $this->data->vote_average; |
114 | 120 | } |
115 | 121 | return 0; |
@@ -130,7 +136,8 @@ discard block |
||
130 | 136 | */ |
131 | 137 | public function getIMDBId() : string |
132 | 138 | { |
133 | - if (isset($this->data->imdb_id)) { |
|
139 | + if (isset($this->data->imdb_id)) |
|
140 | + { |
|
134 | 141 | return $this->data->imdb_id; |
135 | 142 | } |
136 | 143 | return ''; |
@@ -142,7 +149,8 @@ discard block |
||
142 | 149 | */ |
143 | 150 | public function getTagLine() : string |
144 | 151 | { |
145 | - if (isset($this->data->tagline)) { |
|
152 | + if (isset($this->data->tagline)) |
|
153 | + { |
|
146 | 154 | return $this->data->tagline; |
147 | 155 | } |
148 | 156 | return ''; |
@@ -154,7 +162,8 @@ discard block |
||
154 | 162 | */ |
155 | 163 | public function getCollectionId() : int |
156 | 164 | { |
157 | - if (!empty($this->data->belongs_to_collection)) { |
|
165 | + if (!empty($this->data->belongs_to_collection)) |
|
166 | + { |
|
158 | 167 | return (int) $this->data->belongs_to_collection->id; |
159 | 168 | } |
160 | 169 | return 0; |
@@ -186,8 +195,10 @@ discard block |
||
186 | 195 | */ |
187 | 196 | public function getProductionCompanies() : \Generator |
188 | 197 | { |
189 | - if (!empty($this->data->production_companies)) { |
|
190 | - foreach ($this->data->production_companies as $p) { |
|
198 | + if (!empty($this->data->production_companies)) |
|
199 | + { |
|
200 | + foreach ($this->data->production_companies as $p) |
|
201 | + { |
|
191 | 202 | $res = new \stdClass(); |
192 | 203 | $res->id = $p->id; |
193 | 204 | $res->name = $p->name; |
@@ -205,8 +216,10 @@ discard block |
||
205 | 216 | */ |
206 | 217 | public function getProductionCountries() : \Generator |
207 | 218 | { |
208 | - if (!empty($this->data->production_countries)) { |
|
209 | - foreach ($this->data->production_countries as $c) { |
|
219 | + if (!empty($this->data->production_countries)) |
|
220 | + { |
|
221 | + foreach ($this->data->production_countries as $c) |
|
222 | + { |
|
210 | 223 | $res = new \stdClass(); |
211 | 224 | $res->iso_3166_1 = $c->iso_3166_1; |
212 | 225 | $res->name = $c->name; |
@@ -224,7 +237,8 @@ discard block |
||
224 | 237 | { |
225 | 238 | $data = $this->tmdb->getRequest('movie/' . (int) $this->id . '/images', $this->params); |
226 | 239 | |
227 | - foreach ($data->backdrops as $b) { |
|
240 | + foreach ($data->backdrops as $b) |
|
241 | + { |
|
228 | 242 | $image = new Results\Image($this->tmdb, $this->id, $b); |
229 | 243 | yield $image; |
230 | 244 | } |
@@ -238,7 +252,8 @@ discard block |
||
238 | 252 | { |
239 | 253 | $data = $this->tmdb->getRequest('movie/' . (int) $this->id . '/images', $this->params); |
240 | 254 | |
241 | - foreach ($data->posters as $b) { |
|
255 | + foreach ($data->posters as $b) |
|
256 | + { |
|
242 | 257 | $image = new Results\Image($this->tmdb, $this->id, $b); |
243 | 258 | yield $image; |
244 | 259 | } |
@@ -252,7 +267,8 @@ discard block |
||
252 | 267 | { |
253 | 268 | $data = $this->tmdb->getRequest('movie/' . (int) $this->id . '/similar', $this->params); |
254 | 269 | |
255 | - foreach ($data->results as $s) { |
|
270 | + foreach ($data->results as $s) |
|
271 | + { |
|
256 | 272 | $movie = new Results\Movie($this->tmdb, $s); |
257 | 273 | yield $movie; |
258 | 274 | } |
@@ -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 | * |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Crew |
50 | - * @return \Generator|Results\Crew |
|
50 | + * @return \Generator |
|
51 | 51 | */ |
52 | 52 | public function getCrew() : \Generator |
53 | 53 | { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Cast |
64 | - * @return \Generator|Results\Cast |
|
64 | + * @return \Generator |
|
65 | 65 | */ |
66 | 66 | public function getCast() : \Generator |
67 | 67 | { |
@@ -51,8 +51,10 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function getCrew() : \Generator |
53 | 53 | { |
54 | - if (!empty($this->data->crew)) { |
|
55 | - foreach ($this->data->crew as $c) { |
|
54 | + if (!empty($this->data->crew)) |
|
55 | + { |
|
56 | + foreach ($this->data->crew as $c) |
|
57 | + { |
|
56 | 58 | $crew = new Results\Crew($this->tmdb, $c); |
57 | 59 | yield $crew; |
58 | 60 | } |
@@ -65,8 +67,10 @@ discard block |
||
65 | 67 | */ |
66 | 68 | public function getCast() : \Generator |
67 | 69 | { |
68 | - if (!empty($this->data->cast)) { |
|
69 | - foreach ($this->data->cast as $c) { |
|
70 | + if (!empty($this->data->cast)) |
|
71 | + { |
|
72 | + foreach ($this->data->cast as $c) |
|
73 | + { |
|
70 | 74 | $cast = new Results\Cast($this->tmdb, $c); |
71 | 75 | yield $cast; |
72 | 76 | } |
@@ -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 | * |
@@ -26,7 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | /** |
28 | 28 | * Get crew of TV Episode |
29 | - * @return \Generator|Results\Crew |
|
29 | + * @return \Generator |
|
30 | 30 | */ |
31 | 31 | public function getCrew() : \Generator |
32 | 32 | { |
@@ -30,8 +30,10 @@ |
||
30 | 30 | */ |
31 | 31 | public function getCrew() : \Generator |
32 | 32 | { |
33 | - if (!empty($this->data->crew)) { |
|
34 | - foreach ($this->data->crew as $crew) { |
|
33 | + if (!empty($this->data->crew)) |
|
34 | + { |
|
35 | + foreach ($this->data->crew as $crew) |
|
36 | + { |
|
35 | 37 | $crew->gender = null; |
36 | 38 | |
37 | 39 | $return = new Results\Crew($this->tmdb, $crew); |
@@ -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 | * |
@@ -51,9 +51,12 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function getMovieList(array $options = array()) : \Generator |
53 | 53 | { |
54 | - try { |
|
54 | + try |
|
55 | + { |
|
55 | 56 | return $this->getList('genre/movie/list', $options); |
56 | - } catch (TmdbException $ex) { |
|
57 | + } |
|
58 | + catch (TmdbException $ex) |
|
59 | + { |
|
57 | 60 | throw $ex; |
58 | 61 | } |
59 | 62 | } |
@@ -66,9 +69,12 @@ discard block |
||
66 | 69 | */ |
67 | 70 | public function getTVList(array $options = array()) : \Generator |
68 | 71 | { |
69 | - try { |
|
72 | + try |
|
73 | + { |
|
70 | 74 | return $this->getList('genre/tv/list', $options); |
71 | - } catch (TmdbException $ex) { |
|
75 | + } |
|
76 | + catch (TmdbException $ex) |
|
77 | + { |
|
72 | 78 | throw $ex; |
73 | 79 | } |
74 | 80 | } |
@@ -82,17 +88,21 @@ discard block |
||
82 | 88 | */ |
83 | 89 | private function getList(string $type, array $options) : \Generator |
84 | 90 | { |
85 | - try { |
|
91 | + try |
|
92 | + { |
|
86 | 93 | $params = $this->tmdb->checkOptions($options); |
87 | 94 | $response = $this->tmdb->getRequest($type, $params); |
88 | 95 | |
89 | 96 | $genres = []; |
90 | - if (isset($response->genres)) { |
|
97 | + if (isset($response->genres)) |
|
98 | + { |
|
91 | 99 | $genres = $response->genres; |
92 | 100 | } |
93 | 101 | |
94 | 102 | return $this->genreItemGenerator($genres); |
95 | - } catch (TmdbException $ex) { |
|
103 | + } |
|
104 | + catch (TmdbException $ex) |
|
105 | + { |
|
96 | 106 | throw $ex; |
97 | 107 | } |
98 | 108 | } |
@@ -104,7 +114,8 @@ discard block |
||
104 | 114 | */ |
105 | 115 | private function genreItemGenerator(array $results) : \Generator |
106 | 116 | { |
107 | - foreach ($results as $result) { |
|
117 | + foreach ($results as $result) |
|
118 | + { |
|
108 | 119 | yield $result; |
109 | 120 | } |
110 | 121 | } |
@@ -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 | * |
@@ -50,13 +50,16 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function getList(array $options = array()) : \Generator |
52 | 52 | { |
53 | - try { |
|
53 | + try |
|
54 | + { |
|
54 | 55 | $params = $this->tmdb->checkOptions($options); |
55 | 56 | $response = $this->tmdb->getRequest('job/list', $params); |
56 | 57 | |
57 | 58 | $results = []; |
58 | - if (isset($response->jobs)) { |
|
59 | - foreach ($response->jobs as $j) { |
|
59 | + if (isset($response->jobs)) |
|
60 | + { |
|
61 | + foreach ($response->jobs as $j) |
|
62 | + { |
|
60 | 63 | $result = new \stdClass(); |
61 | 64 | $result->department = $j->department; |
62 | 65 | $result->jobs = $j->job_list; |
@@ -64,7 +67,9 @@ discard block |
||
64 | 67 | $results[] = $result; |
65 | 68 | } |
66 | 69 | } |
67 | - } catch (TmdbException $ex) { |
|
70 | + } |
|
71 | + catch (TmdbException $ex) |
|
72 | + { |
|
68 | 73 | throw $ex; |
69 | 74 | } |
70 | 75 | return $this->genreItemGenerator($results); |
@@ -77,7 +82,8 @@ discard block |
||
77 | 82 | */ |
78 | 83 | private function genreItemGenerator(array $results) : \Generator |
79 | 84 | { |
80 | - foreach ($results as $result) { |
|
85 | + foreach ($results as $result) |
|
86 | + { |
|
81 | 87 | yield $result; |
82 | 88 | } |
83 | 89 | } |
@@ -1,4 +1,4 @@ |
||
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. |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | { |
63 | 63 | $logger = new Logger($this->loggerName); |
64 | 64 | |
65 | - foreach ($this->handlersConfig as $config) { |
|
65 | + foreach ($this->handlersConfig as $config) |
|
66 | + { |
|
66 | 67 | $handler = $this->newHandler($config['class'], $config['params']); |
67 | 68 | $logger->pushHandler($handler); |
68 | 69 | } |
@@ -80,7 +81,8 @@ discard block |
||
80 | 81 | { |
81 | 82 | $reflection = new \ReflectionClass($class); |
82 | 83 | |
83 | - if (!$reflection->implementsInterface('Monolog\Handler\HandlerInterface')) { |
|
84 | + if (!$reflection->implementsInterface('Monolog\Handler\HandlerInterface')) |
|
85 | + { |
|
84 | 86 | throw new \InvalidArgumentException(); |
85 | 87 | } |
86 | 88 |
@@ -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 | * |
@@ -87,7 +87,8 @@ |
||
87 | 87 | */ |
88 | 88 | public function __construct(TmdbInterface $tmdb, \stdClass $result) |
89 | 89 | { |
90 | - if (!isset($result->episode_count)) { |
|
90 | + if (!isset($result->episode_count)) |
|
91 | + { |
|
91 | 92 | $result->episode_count = null; |
92 | 93 | } |
93 | 94 | parent::__construct($tmdb, $result); |
@@ -1,4 +1,4 @@ |
||
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. |
@@ -96,13 +96,16 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function __construct(TmdbInterface $tmdb, \stdClass $result) |
98 | 98 | { |
99 | - if (!isset($result->overview)) { |
|
99 | + if (!isset($result->overview)) |
|
100 | + { |
|
100 | 101 | $result->overview = null; |
101 | 102 | } |
102 | - if (!isset($result->production_code)) { |
|
103 | + if (!isset($result->production_code)) |
|
104 | + { |
|
103 | 105 | $result->production_code = null; |
104 | 106 | } |
105 | - if (!isset($result->guest_stars)) { |
|
107 | + if (!isset($result->guest_stars)) |
|
108 | + { |
|
106 | 109 | $result->guest_stars = null; |
107 | 110 | } |
108 | 111 | |
@@ -146,8 +149,10 @@ discard block |
||
146 | 149 | */ |
147 | 150 | public function getGuestStars() : \Generator |
148 | 151 | { |
149 | - if (isset($this->guest_stars)) { |
|
150 | - foreach ($this->guest_stars as $gs) { |
|
152 | + if (isset($this->guest_stars)) |
|
153 | + { |
|
154 | + foreach ($this->guest_stars as $gs) |
|
155 | + { |
|
151 | 156 | $gs->gender = null; |
152 | 157 | $gs->cast_id = null; |
153 | 158 |
@@ -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 | * |