1 | <?php |
||
15 | class TmdbSearchService |
||
16 | { |
||
17 | private $apiKey; |
||
18 | private $client; |
||
19 | private $logger; |
||
20 | private $cache; |
||
21 | private const ApiUrl = 'https://api.themoviedb.org/3'; |
||
22 | |||
23 | 9 | public function __construct(LoggerInterface $logger, ClientInterface $client, CacheInterface $cache) |
|
30 | |||
31 | /** |
||
32 | * @param string $query |
||
33 | * @param string $locale |
||
34 | * @param array $data |
||
35 | * |
||
36 | * @throws TmdbMovieNotFoundException |
||
37 | * @throws TmdbRequestLimitException |
||
38 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
39 | * |
||
40 | * @return array |
||
41 | */ |
||
42 | 1 | public function findMoviesByQuery(string $query, string $locale = 'en', $data = []): array |
|
56 | |||
57 | /** |
||
58 | * @param int $tmdb_id |
||
59 | * @param string $locale |
||
60 | * |
||
61 | * @throws TmdbMovieNotFoundException |
||
62 | * @throws TmdbRequestLimitException |
||
63 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
64 | * |
||
65 | * @return array |
||
66 | */ |
||
67 | 1 | public function findMovieById(int $tmdb_id, string $locale = 'en'): array |
|
91 | |||
92 | /** |
||
93 | * @param int $movieId |
||
94 | * @param string $locale |
||
95 | * |
||
96 | * @throws TmdbMovieNotFoundException |
||
97 | * @throws TmdbRequestLimitException |
||
98 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | public function findActorsByMovieId(int $movieId, string $locale = 'en'): array |
||
113 | |||
114 | /** |
||
115 | * @param int $personId |
||
116 | * @param string $locale |
||
117 | * |
||
118 | * @throws TmdbMovieNotFoundException |
||
119 | * @throws TmdbRequestLimitException |
||
120 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | public function findActorById(int $personId, string $locale = 'en'): array |
||
144 | |||
145 | /** |
||
146 | * @param int $personId |
||
147 | * @param string $locale |
||
148 | * |
||
149 | * @throws TmdbMovieNotFoundException |
||
150 | * @throws TmdbRequestLimitException |
||
151 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
152 | * |
||
153 | * @return array |
||
154 | */ |
||
155 | public function findActorTranslationsById(int $personId, string $locale = 'en'): array |
||
168 | |||
169 | /** |
||
170 | * @param int $tmdb_id |
||
171 | * |
||
172 | * @throws TmdbMovieNotFoundException |
||
173 | * @throws TmdbRequestLimitException |
||
174 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | public function findMovieTranslationsById(int $tmdb_id): array |
||
188 | |||
189 | /** |
||
190 | * @param int $tmdb_id |
||
191 | * @param int $page |
||
192 | * |
||
193 | * @throws TmdbMovieNotFoundException |
||
194 | * @throws TmdbRequestLimitException |
||
195 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
196 | * |
||
197 | * @return array |
||
198 | */ |
||
199 | public function findSimilarMoviesById(int $tmdb_id, int $page = 1): array |
||
210 | |||
211 | /** |
||
212 | * @param string $url |
||
213 | * @param string $method |
||
214 | * @param array $params |
||
215 | * |
||
216 | * @throws TmdbMovieNotFoundException |
||
217 | * @throws TmdbRequestLimitException |
||
218 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
219 | * |
||
220 | * @return array |
||
221 | */ |
||
222 | 2 | private function request(string $url, string $method = 'GET', array $params = []): array |
|
263 | |||
264 | 2 | private function arrayAsString(array $array): string |
|
277 | |||
278 | 2 | private function getCacheKeyFromParams(string $url, string $method = 'GET', array $params = []): string |
|
284 | |||
285 | /** |
||
286 | * @param string $url |
||
287 | * @param string $method |
||
288 | * @param array $params |
||
289 | * |
||
290 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
291 | * |
||
292 | * @return array|null |
||
293 | */ |
||
294 | 2 | private function getResponseFromCache(string $url, string $method = 'GET', array $params = []): ?array |
|
302 | } |
||
303 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.