This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php declare(strict_types = 1); |
||
2 | |||
3 | namespace ikoene\Marvel; |
||
4 | |||
5 | use Guzzle; |
||
6 | use Guzzle\Http\Client as GuzzleClient; |
||
7 | use Guzzle\Http\Message\Response; |
||
8 | use ikoene\Marvel\DataWrapper\CharacterDataWrapper; |
||
9 | use ikoene\Marvel\DataWrapper\ComicDataWrapper; |
||
10 | use ikoene\Marvel\DataWrapper\CreatorDataWrapper; |
||
11 | use ikoene\Marvel\DataWrapper\EventDataWrapper; |
||
12 | use ikoene\Marvel\DataWrapper\SeriesDataWrapper; |
||
13 | use ikoene\Marvel\DataWrapper\StoryDataWrapper; |
||
14 | use ikoene\Marvel\Entity\CharacterFilter; |
||
15 | use ikoene\Marvel\Entity\ComicFilter; |
||
16 | use ikoene\Marvel\Entity\CreatorFilter; |
||
17 | use ikoene\Marvel\Entity\EventFilter; |
||
18 | use ikoene\Marvel\Entity\SeriesFilter; |
||
19 | use ikoene\Marvel\Entity\StoryFilter; |
||
20 | use JMS\Serializer\SerializerBuilder; |
||
21 | |||
22 | /** |
||
23 | * Class Client |
||
24 | * @package ikoene\Marvel |
||
25 | */ |
||
26 | class Client |
||
27 | { |
||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $baseUrl = 'http://gateway.marvel.com/v1/public/'; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $publicApiKey; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $privateApiKey; |
||
42 | |||
43 | /** |
||
44 | * Client constructor. |
||
45 | * |
||
46 | * @param string $publicApiKey |
||
47 | * @param string $privateApiKey |
||
48 | */ |
||
49 | public function __construct(string $publicApiKey, string $privateApiKey) |
||
50 | { |
||
51 | $this->publicApiKey = $publicApiKey; |
||
52 | $this->privateApiKey = $privateApiKey; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Fetches lists of comic characters with optional filters. |
||
57 | * |
||
58 | * @param CharacterFilter|null $characterFilter |
||
59 | * |
||
60 | * @return CharacterDataWrapper |
||
61 | */ |
||
62 | public function getCharacters(CharacterFilter $characterFilter = null) : CharacterDataWrapper |
||
63 | { |
||
64 | $response = $this->call('characters', $characterFilter); |
||
65 | |||
66 | $formattedResponse = $this->formatResponse($response, CharacterDataWrapper::class); |
||
67 | |||
68 | return $formattedResponse; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * This method fetches a single character resource. |
||
73 | * |
||
74 | * @param int $id |
||
75 | * |
||
76 | * @return CharacterDataWrapper |
||
77 | */ |
||
78 | View Code Duplication | public function getCharacter(int $id) : CharacterDataWrapper |
|
0 ignored issues
–
show
|
|||
79 | { |
||
80 | $response = $this->call('characters/' . $id); |
||
81 | |||
82 | $formattedResponse = $this->formatResponse($response, CharacterDataWrapper::class); |
||
83 | |||
84 | return $formattedResponse; |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Fetches lists of comics containing a specific character, with optional filters. |
||
89 | * |
||
90 | * @param int $id |
||
91 | * @param ComicFilter $comicFilter |
||
92 | * |
||
93 | * @return ComicDataWrapper |
||
94 | */ |
||
95 | View Code Duplication | public function getComicsForCharacter(int $id, ComicFilter $comicFilter = null) : ComicDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
96 | { |
||
97 | $response = $this->call('characters/' . $id . '/comics', $comicFilter); |
||
98 | |||
99 | $formattedResponse = $this->formatResponse($response, ComicDataWrapper::class); |
||
100 | |||
101 | return $formattedResponse; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Fetches lists of events in which a specific character appears, with optional filters. |
||
106 | * |
||
107 | * @param int $id |
||
108 | * @param EventFilter $eventFilter |
||
109 | * |
||
110 | * @return EventDataWrapper |
||
111 | */ |
||
112 | public function getEventsForCharacter(int $id, EventFilter $eventFilter = null) : EventDataWrapper |
||
113 | { |
||
114 | $response = $this->call('characters/' . $id . '/events', $eventFilter); |
||
115 | |||
116 | $formattedResponse = $this->formatResponse($response, EventDataWrapper::class); |
||
117 | |||
118 | return $formattedResponse; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Fetches lists of comic series in which a specific character appears, with optional filters. |
||
123 | * |
||
124 | * @param int $id |
||
125 | * @param SeriesFilter $seriesFilter |
||
126 | * |
||
127 | * @return SeriesDataWrapper |
||
128 | */ |
||
129 | View Code Duplication | public function getSeriesForCharacter(int $id, SeriesFilter $seriesFilter = null) : SeriesDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
130 | { |
||
131 | $response = $this->call('characters/' . $id . '/series', $seriesFilter); |
||
132 | |||
133 | $formattedResponse = $this->formatResponse($response, SeriesDataWrapper::class); |
||
134 | |||
135 | return $formattedResponse; |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * Fetches lists of comic stories featuring a specific character with optional filters. |
||
140 | * |
||
141 | * @param int $id |
||
142 | * @param StoryFilter $storyFilter |
||
143 | * |
||
144 | * @return StoryDataWrapper |
||
145 | */ |
||
146 | View Code Duplication | public function getStoriesForCharacter(int $id, StoryFilter $storyFilter = null) : StoryDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
147 | { |
||
148 | $response = $this->call('characters/' . $id . '/stories', $storyFilter); |
||
149 | |||
150 | $formattedResponse = $this->formatResponse($response, StoryDataWrapper::class); |
||
151 | |||
152 | return $formattedResponse; |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * Fetches lists of comics with optional filters. |
||
157 | * |
||
158 | * @param ComicFilter|null $comicFilter |
||
159 | * |
||
160 | * @return ComicDataWrapper |
||
161 | */ |
||
162 | View Code Duplication | public function getComics(ComicFilter $comicFilter = null) : ComicDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
163 | { |
||
164 | $response = $this->call('comics', $comicFilter); |
||
165 | |||
166 | $formattedResponse = $this->formatResponse($response, ComicDataWrapper::class); |
||
167 | |||
168 | return $formattedResponse; |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * This method fetches a single comic resource. |
||
173 | * |
||
174 | * @param int $id |
||
175 | * |
||
176 | * @return ComicDataWrapper |
||
177 | */ |
||
178 | View Code Duplication | public function getComic(int $id) : ComicDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
179 | { |
||
180 | $response = $this->call('comics/' . $id); |
||
181 | |||
182 | $formattedResponse = $this->formatResponse($response, ComicDataWrapper::class); |
||
183 | |||
184 | return $formattedResponse; |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * Fetches lists of characters which appear in a specific comic with optional filters. |
||
189 | * |
||
190 | * @param int $id |
||
191 | * @param CharacterFilter $characterFilter |
||
192 | * |
||
193 | * @return CharacterDataWrapper |
||
194 | */ |
||
195 | View Code Duplication | public function getCharactersForComic(int $id, CharacterFilter $characterFilter = null) : CharacterDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
196 | { |
||
197 | $response = $this->call('comics/' . $id . '/characters', $characterFilter); |
||
198 | |||
199 | $formattedResponse = $this->formatResponse($response, CharacterDataWrapper::class); |
||
200 | |||
201 | return $formattedResponse; |
||
202 | } |
||
203 | |||
204 | /** |
||
205 | * Fetches lists of comic creators whose work appears in a specific comic, with optional filters. |
||
206 | * |
||
207 | * @param int $id |
||
208 | * @param CreatorFilter $creatorFilter |
||
209 | * |
||
210 | * @return CreatorDataWrapper |
||
211 | */ |
||
212 | View Code Duplication | public function getCreatorsForComics(int $id, CreatorFilter $creatorFilter = null) : CreatorDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
213 | { |
||
214 | $response = $this->call('comics/' . $id . '/creators', $creatorFilter); |
||
215 | |||
216 | $formattedResponse = $this->formatResponse($response, CreatorDataWrapper::class); |
||
217 | |||
218 | return $formattedResponse; |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * Fetches lists of events in which a specific comic appears, with optional filters. |
||
223 | * |
||
224 | * @param int $id |
||
225 | * @param EventFilter $eventFilter |
||
226 | * |
||
227 | * @return EventDataWrapper |
||
228 | */ |
||
229 | public function getEventsForComics(int $id, EventFilter $eventFilter = null) : EventDataWrapper |
||
230 | { |
||
231 | $response = $this->call('comics/' . $id . '/events', $eventFilter); |
||
232 | |||
233 | $formattedResponse = $this->formatResponse($response, EventDataWrapper::class); |
||
234 | |||
235 | return $formattedResponse; |
||
236 | } |
||
237 | |||
238 | /** |
||
239 | * Fetches lists of comic stories in a specific comic issue, with optional filters. |
||
240 | * |
||
241 | * @param int $id |
||
242 | * @param EventFilter $storyFilter |
||
243 | * |
||
244 | * @return StoryDataWrapper |
||
245 | */ |
||
246 | View Code Duplication | public function getStoriesForComics(int $id, EventFilter $storyFilter = null) : StoryDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
247 | { |
||
248 | $response = $this->call('comics/' . $id . '/stories', $storyFilter); |
||
249 | |||
250 | $formattedResponse = $this->formatResponse($response, StoryDataWrapper::class); |
||
251 | |||
252 | return $formattedResponse; |
||
253 | } |
||
254 | |||
255 | /** |
||
256 | * Fetches lists of events with optional filters. |
||
257 | * |
||
258 | * @param EventFilter|null $eventFilter |
||
259 | * |
||
260 | * @return EventDataWrapper |
||
261 | */ |
||
262 | public function getEvents(EventFilter $eventFilter = null) : EventDataWrapper |
||
263 | { |
||
264 | $response = $this->call('events', $eventFilter); |
||
265 | |||
266 | $formattedResponse = $this->formatResponse($response, EventDataWrapper::class); |
||
267 | |||
268 | return $formattedResponse; |
||
269 | } |
||
270 | |||
271 | /** |
||
272 | * This method fetches a single event resource. |
||
273 | * |
||
274 | * @param int $id |
||
275 | * |
||
276 | * @return EventDataWrapper |
||
277 | */ |
||
278 | public function getEvent(int $id) : EventDataWrapper |
||
279 | { |
||
280 | $response = $this->call('events/' . $id); |
||
281 | |||
282 | $formattedResponse = $this->formatResponse($response, EventDataWrapper::class); |
||
283 | |||
284 | return $formattedResponse; |
||
285 | } |
||
286 | |||
287 | /** |
||
288 | * Fetches lists of characters which appear in a specific event, with optional filters. |
||
289 | * |
||
290 | * @param int $id |
||
291 | * @param CharacterFilter $characterFilter |
||
292 | * |
||
293 | * @return CharacterDataWrapper |
||
294 | */ |
||
295 | View Code Duplication | public function getCharactersForEvent(int $id, CharacterFilter $characterFilter = null) : CharacterDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
296 | { |
||
297 | $response = $this->call('events/' . $id . '/characters', $characterFilter); |
||
298 | |||
299 | $formattedResponse = $this->formatResponse($response, CharacterDataWrapper::class); |
||
300 | |||
301 | return $formattedResponse; |
||
302 | } |
||
303 | |||
304 | /** |
||
305 | * Fetches lists of comics which take place during a specific event, with optional filters. |
||
306 | * |
||
307 | * @param int $id |
||
308 | * @param ComicFilter $comicFilter |
||
309 | * |
||
310 | * @return ComicDataWrapper |
||
311 | */ |
||
312 | View Code Duplication | public function getComicsForEvent(int $id, ComicFilter $comicFilter = null) : ComicDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
313 | { |
||
314 | $response = $this->call('events/' . $id . '/comics', $comicFilter); |
||
315 | |||
316 | $formattedResponse = $this->formatResponse($response, ComicDataWrapper::class); |
||
317 | |||
318 | return $formattedResponse; |
||
319 | } |
||
320 | |||
321 | /** |
||
322 | * Fetches lists of comic creators whose work appears in a specific event, with optional filters. |
||
323 | * |
||
324 | * @param int $id |
||
325 | * @param CreatorFilter $creatorFilter |
||
326 | * |
||
327 | * @return CreatorDataWrapper |
||
328 | */ |
||
329 | View Code Duplication | public function getCreatorsForEvent(int $id, CreatorFilter $creatorFilter = null) : CreatorDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
330 | { |
||
331 | $response = $this->call('events/' . $id . '/creators', $creatorFilter); |
||
332 | |||
333 | $formattedResponse = $this->formatResponse($response, CreatorDataWrapper::class); |
||
334 | |||
335 | return $formattedResponse; |
||
336 | } |
||
337 | |||
338 | /** |
||
339 | * Fetches lists of comic series in which a specific event takes place, with optional filters. |
||
340 | * |
||
341 | * @param int $id |
||
342 | * @param SeriesFilter $seriesFilter |
||
343 | * |
||
344 | * @return SeriesDataWrapper |
||
345 | */ |
||
346 | View Code Duplication | public function getSeriesForEvent(int $id, SeriesFilter $seriesFilter = null) : SeriesDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
347 | { |
||
348 | $response = $this->call('events/' . $id . '/series', $seriesFilter); |
||
349 | |||
350 | $formattedResponse = $this->formatResponse($response, SeriesDataWrapper::class); |
||
351 | |||
352 | return $formattedResponse; |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * Fetches lists of comic stories from a specific event, with optional filters. |
||
357 | * |
||
358 | * @param int $id |
||
359 | * @param StoryFilter $storyFilter |
||
360 | * |
||
361 | * @return StoryDataWrapper |
||
362 | */ |
||
363 | View Code Duplication | public function getStoriesForEvent(int $id, StoryFilter $storyFilter = null) : StoryDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
364 | { |
||
365 | $response = $this->call('events/' . $id . '/stories', $storyFilter); |
||
366 | |||
367 | $formattedResponse = $this->formatResponse($response, StoryDataWrapper::class); |
||
368 | |||
369 | return $formattedResponse; |
||
370 | } |
||
371 | |||
372 | /** |
||
373 | * Fetches lists of comic creators with optional filters. |
||
374 | * |
||
375 | * @param CreatorFilter|null $creatorFilter |
||
376 | * |
||
377 | * @return CreatorDataWrapper |
||
378 | */ |
||
379 | View Code Duplication | public function getCreators(CreatorFilter $creatorFilter = null) : CreatorDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
380 | { |
||
381 | $response = $this->call('creators', $creatorFilter); |
||
382 | |||
383 | $formattedResponse = $this->formatResponse($response, CreatorDataWrapper::class); |
||
384 | |||
385 | return $formattedResponse; |
||
386 | } |
||
387 | |||
388 | /** |
||
389 | * This method fetches a single creator resource. |
||
390 | * |
||
391 | * @param int $id |
||
392 | * |
||
393 | * @return CreatorDataWrapper |
||
394 | */ |
||
395 | View Code Duplication | public function getCreator(int $id) : CreatorDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
396 | { |
||
397 | $response = $this->call('creators/' . $id); |
||
398 | |||
399 | $formattedResponse = $this->formatResponse($response, CreatorDataWrapper::class); |
||
400 | |||
401 | return $formattedResponse; |
||
402 | } |
||
403 | |||
404 | /** |
||
405 | * Fetches lists of events featuring the work of a specific creator with optional filters. |
||
406 | * |
||
407 | * @param int $id |
||
408 | * @param CreatorFilter $creatorFilter |
||
409 | * |
||
410 | * @return CreatorDataWrapper |
||
411 | */ |
||
412 | View Code Duplication | public function getComicsForCreator(int $id, CreatorFilter $creatorFilter = null) : CreatorDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
413 | { |
||
414 | $response = $this->call('creators/' . $id . '/comics', $creatorFilter); |
||
415 | |||
416 | $formattedResponse = $this->formatResponse($response, CreatorDataWrapper::class); |
||
417 | |||
418 | return $formattedResponse; |
||
419 | } |
||
420 | |||
421 | /** |
||
422 | * Fetches lists of comic series in which a specific creator's work appears, with optional filters. |
||
423 | * |
||
424 | * @param int $id |
||
425 | * @param SeriesFilter $seriesFilter |
||
426 | * |
||
427 | * @return SeriesDataWrapper |
||
428 | */ |
||
429 | View Code Duplication | public function getSeriesForCreator(int $id, SeriesFilter $seriesFilter = null) : SeriesDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
430 | { |
||
431 | $response = $this->call('creators/' . $id . '/series', $seriesFilter); |
||
432 | |||
433 | $formattedResponse = $this->formatResponse($response, SeriesDataWrapper::class); |
||
434 | |||
435 | return $formattedResponse; |
||
436 | } |
||
437 | |||
438 | /** |
||
439 | * Fetches lists of comic stories by a specific creator with optional filters. |
||
440 | * |
||
441 | * @param int $id |
||
442 | * @param StoryFilter $storyFilter |
||
443 | * |
||
444 | * @return StoryDataWrapper |
||
445 | */ |
||
446 | View Code Duplication | public function getStoriesForCreator(int $id, StoryFilter $storyFilter = null) : StoryDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
447 | { |
||
448 | $response = $this->call('creators/' . $id . '/stories', $storyFilter); |
||
449 | |||
450 | $formattedResponse = $this->formatResponse($response, StoryDataWrapper::class); |
||
451 | |||
452 | return $formattedResponse; |
||
453 | } |
||
454 | |||
455 | /** |
||
456 | * Fetches lists of comic series with optional filters. |
||
457 | * |
||
458 | * @param SeriesFilter|null $seriesFilter |
||
459 | * |
||
460 | * @return SeriesDataWrapper |
||
461 | */ |
||
462 | View Code Duplication | public function getSeries(SeriesFilter $seriesFilter = null) : SeriesDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
463 | { |
||
464 | $response = $this->call('series', $seriesFilter); |
||
465 | |||
466 | $formattedResponse = $this->formatResponse($response, SeriesDataWrapper::class); |
||
467 | |||
468 | return $formattedResponse; |
||
469 | } |
||
470 | |||
471 | /** |
||
472 | * This method fetches a single comic series resource. |
||
473 | * |
||
474 | * @param int $id |
||
475 | * |
||
476 | * @return SeriesDataWrapper |
||
477 | */ |
||
478 | View Code Duplication | public function getASeries(int $id) : SeriesDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
479 | { |
||
480 | $response = $this->call('series/' . $id); |
||
481 | |||
482 | $formattedResponse = $this->formatResponse($response, SeriesDataWrapper::class); |
||
483 | |||
484 | return $formattedResponse; |
||
485 | } |
||
486 | |||
487 | /** |
||
488 | * Fetches lists of characters which appear in specific series, with optional filters. |
||
489 | * |
||
490 | * @param int $id |
||
491 | * @param CharacterFilter $characterFilter |
||
492 | * |
||
493 | * @return CharacterDataWrapper |
||
494 | */ |
||
495 | View Code Duplication | public function getCharactersForSeries(int $id, CharacterFilter $characterFilter = null) : CharacterDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
496 | { |
||
497 | $response = $this->call('series/' . $id . '/characters', $characterFilter); |
||
498 | |||
499 | $formattedResponse = $this->formatResponse($response, CharacterDataWrapper::class); |
||
500 | |||
501 | return $formattedResponse; |
||
502 | } |
||
503 | |||
504 | /** |
||
505 | * Fetches lists of comics which are published as part of a specific series, with optional filters. |
||
506 | * |
||
507 | * @param int $id |
||
508 | * @param ComicFilter $comicFilter |
||
509 | * |
||
510 | * @return ComicDataWrapper |
||
511 | */ |
||
512 | View Code Duplication | public function getComicsForSeries(int $id, ComicFilter $comicFilter = null) : ComicDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
513 | { |
||
514 | $response = $this->call('series/' . $id . '/comics', $comicFilter); |
||
515 | |||
516 | $formattedResponse = $this->formatResponse($response, ComicDataWrapper::class); |
||
517 | |||
518 | return $formattedResponse; |
||
519 | } |
||
520 | |||
521 | /** |
||
522 | * Fetches lists of comic creators whose work appears in a specific series, with optional filters. |
||
523 | * |
||
524 | * @param int $id |
||
525 | * @param CreatorFilter $creatorFilter |
||
526 | * |
||
527 | * @return CreatorDataWrapper |
||
528 | */ |
||
529 | View Code Duplication | public function getCreatorsForSeries(int $id, CreatorFilter $creatorFilter = null) : CreatorDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
530 | { |
||
531 | $response = $this->call('series/' . $id . '/creators', $creatorFilter); |
||
532 | |||
533 | $formattedResponse = $this->formatResponse($response, CreatorDataWrapper::class); |
||
534 | |||
535 | return $formattedResponse; |
||
536 | } |
||
537 | |||
538 | /** |
||
539 | * Fetches lists of events which occur in a specific series, with optional filters. |
||
540 | * |
||
541 | * @param int $id |
||
542 | * @param EventFilter $eventFilter |
||
543 | * |
||
544 | * @return EventDataWrapper |
||
545 | */ |
||
546 | public function getEventsForSeries(int $id, EventFilter $eventFilter = null) : EventDataWrapper |
||
547 | { |
||
548 | $response = $this->call('series/' . $id . '/events', $eventFilter); |
||
549 | |||
550 | $formattedResponse = $this->formatResponse($response, EventDataWrapper::class); |
||
551 | |||
552 | return $formattedResponse; |
||
553 | } |
||
554 | |||
555 | /** |
||
556 | * Fetches lists of comic stories from a specific series with optional filters. |
||
557 | * |
||
558 | * @param int $id |
||
559 | * @param StoryFilter $storyFilter |
||
560 | * |
||
561 | * @return StoryDataWrapper |
||
562 | */ |
||
563 | View Code Duplication | public function getStoriesForSeries(int $id, StoryFilter $storyFilter = null) : StoryDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
564 | { |
||
565 | $response = $this->call('series/' . $id . '/stories', $storyFilter); |
||
566 | |||
567 | $formattedResponse = $this->formatResponse($response, StoryDataWrapper::class); |
||
568 | |||
569 | return $formattedResponse; |
||
570 | } |
||
571 | |||
572 | /** |
||
573 | * Fetches lists of comic stories with optional filters. |
||
574 | * |
||
575 | * @param StoryFilter|null $storyFilter |
||
576 | * |
||
577 | * @return StoryDataWrapper |
||
578 | */ |
||
579 | View Code Duplication | public function getStories(StoryFilter $storyFilter = null) : StoryDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
580 | { |
||
581 | $response = $this->call('stories', $storyFilter); |
||
582 | |||
583 | $formattedResponse = $this->formatResponse($response, StoryDataWrapper::class); |
||
584 | |||
585 | return $formattedResponse; |
||
586 | } |
||
587 | |||
588 | /** |
||
589 | * This method fetches a single comic story resource. |
||
590 | * |
||
591 | * @param int $id |
||
592 | * |
||
593 | * @return StoryDataWrapper |
||
594 | */ |
||
595 | View Code Duplication | public function getStory(int $id) : StoryDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
596 | { |
||
597 | $response = $this->call('stories/' . $id); |
||
598 | |||
599 | $formattedResponse = $this->formatResponse($response, StoryDataWrapper::class); |
||
600 | |||
601 | return $formattedResponse; |
||
602 | } |
||
603 | |||
604 | /** |
||
605 | * Fetches lists of comic characters appearing in a single story, with optional filters. |
||
606 | * |
||
607 | * @param int $id |
||
608 | * @param CharacterFilter $characterFilter |
||
609 | * |
||
610 | * @return CharacterDataWrapper |
||
611 | */ |
||
612 | View Code Duplication | public function getCharactersForStory(int $id, CharacterFilter $characterFilter = null) : CharacterDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
613 | { |
||
614 | $response = $this->call('stories/' . $id . '/characters', $characterFilter); |
||
615 | |||
616 | $formattedResponse = $this->formatResponse($response, CharacterDataWrapper::class); |
||
617 | |||
618 | return $formattedResponse; |
||
619 | } |
||
620 | |||
621 | /** |
||
622 | * Fetches lists of comics in which a specific story appears, with optional filters. |
||
623 | * |
||
624 | * @param int $id |
||
625 | * @param ComicFilter $comicFilter |
||
626 | * |
||
627 | * @return ComicDataWrapper |
||
628 | */ |
||
629 | View Code Duplication | public function getComicsForStory(int $id, ComicFilter $comicFilter = null) : ComicDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
630 | { |
||
631 | $response = $this->call('stories/' . $id . '/comics', $comicFilter); |
||
632 | |||
633 | $formattedResponse = $this->formatResponse($response, ComicDataWrapper::class); |
||
634 | |||
635 | return $formattedResponse; |
||
636 | } |
||
637 | |||
638 | /** |
||
639 | * Fetches lists of comic creators whose work appears in a specific story, with optional filters. |
||
640 | * |
||
641 | * @param int $id |
||
642 | * @param CreatorFilter $creatorFilter |
||
643 | * |
||
644 | * @return CreatorDataWrapper |
||
645 | */ |
||
646 | View Code Duplication | public function getCreatorsForStory(int $id, CreatorFilter $creatorFilter = null) : CreatorDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
647 | { |
||
648 | $response = $this->call('stories/' . $id . '/creators', $creatorFilter); |
||
649 | |||
650 | $formattedResponse = $this->formatResponse($response, CreatorDataWrapper::class); |
||
651 | |||
652 | return $formattedResponse; |
||
653 | } |
||
654 | |||
655 | /** |
||
656 | * Fetches lists of events in which a specific story appears, with optional filters. |
||
657 | * |
||
658 | * @param int $id |
||
659 | * @param EventFilter $eventFilter |
||
660 | * |
||
661 | * @return EventDataWrapper |
||
662 | */ |
||
663 | public function getEventsForStory(int $id, EventFilter $eventFilter = null) : EventDataWrapper |
||
664 | { |
||
665 | $response = $this->call('stories/' . $id . '/events', $eventFilter); |
||
666 | |||
667 | $formattedResponse = $this->formatResponse($response, EventDataWrapper::class); |
||
668 | |||
669 | return $formattedResponse; |
||
670 | } |
||
671 | |||
672 | /** |
||
673 | * Fetches lists of comic series in which the specified story takes place. |
||
674 | * |
||
675 | * @param int $id |
||
676 | * @param SeriesFilter $seriesFilter |
||
677 | * |
||
678 | * @return SeriesDataWrapper |
||
679 | */ |
||
680 | View Code Duplication | public function getSeriesForStory(int $id, SeriesFilter $seriesFilter = null) : SeriesDataWrapper |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
681 | { |
||
682 | $response = $this->call('stories/' . $id . '/series', $seriesFilter); |
||
683 | |||
684 | $formattedResponse = $this->formatResponse($response, SeriesDataWrapper::class); |
||
685 | |||
686 | return $formattedResponse; |
||
687 | } |
||
688 | |||
689 | /** |
||
690 | * @param string $operation |
||
691 | * @param object|null $query |
||
692 | * |
||
693 | * @return Response |
||
694 | */ |
||
695 | private function call(string $operation, $query = null) : Response |
||
696 | { |
||
697 | $url = $this->baseUrl . $operation; |
||
698 | |||
699 | $params = array(); |
||
700 | if (!empty($query)) { |
||
701 | $params = get_object_vars($query); |
||
702 | } |
||
703 | |||
704 | return $this->send($url, $params); |
||
705 | } |
||
706 | |||
707 | /** |
||
708 | * @param string $url |
||
709 | * @param array $params |
||
710 | * |
||
711 | * @return Response |
||
712 | */ |
||
713 | private function send(string $url, array $params = array()) : Response |
||
714 | { |
||
715 | $client = new GuzzleClient($url); |
||
716 | |||
717 | $request = $client->get(); |
||
718 | |||
719 | // Build query |
||
720 | $query = $request->getQuery(); |
||
721 | |||
722 | $query->set('ts', time()); |
||
723 | $query->set('apikey', $this->publicApiKey); |
||
724 | $query->set('hash', md5(time() . $this->privateApiKey . $this->publicApiKey)); |
||
725 | |||
726 | // Add the parameters to the query |
||
727 | foreach (array_filter($params) as $key => $value) { |
||
728 | $query->set($key, $value); |
||
729 | } |
||
730 | |||
731 | return $request->send(); |
||
732 | } |
||
733 | |||
734 | /** |
||
735 | * @param Response $response |
||
736 | * @param string $dataWrapper |
||
737 | * |
||
738 | * @return Object |
||
739 | */ |
||
740 | private function formatResponse(Response $response, string $dataWrapper) |
||
741 | { |
||
742 | $serializer = SerializerBuilder::create() |
||
743 | ->addMetadataDir(__DIR__ . '/Serializer/', 'ikoene\Marvel') |
||
744 | ->build(); |
||
745 | |||
746 | return $serializer->deserialize($response->getBody(), $dataWrapper, 'json'); |
||
747 | } |
||
748 | } |
||
749 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.