1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Tmdb package. |
4
|
|
|
* |
5
|
|
|
* (c) Vincent Faliès <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @author Vincent Faliès <[email protected]> |
11
|
|
|
* @copyright Copyright (c) 2017 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
namespace vfalies\tmdb\Items; |
16
|
|
|
|
17
|
|
|
use vfalies\tmdb\Abstracts\Item; |
18
|
|
|
use vfalies\tmdb\Results\Crew; |
19
|
|
|
use vfalies\tmdb\Results\Cast; |
20
|
|
|
use vfalies\tmdb\Interfaces\TmdbInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Movie Credit class |
24
|
|
|
* @package Tmdb |
25
|
|
|
* @author Vincent Faliès <[email protected]> |
26
|
|
|
* @copyright Copyright (c) 2017 |
27
|
|
|
*/ |
28
|
|
View Code Duplication |
class MovieCredit extends Item |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Crew |
32
|
|
|
* @var \stdClass |
33
|
|
|
*/ |
34
|
|
|
protected $crew; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Constructor |
38
|
|
|
* @param \vfalies\tmdb\Interfaces\TmdbInterface $tmdb |
39
|
|
|
* @param int $movie_id |
40
|
|
|
* @param array $options |
41
|
|
|
*/ |
42
|
10 |
|
public function __construct(TmdbInterface $tmdb, $movie_id, array $options = array()) |
43
|
|
|
{ |
44
|
10 |
|
parent::__construct($tmdb, '/credits', $options, 'movie/' . $movie_id); |
45
|
10 |
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Crew |
49
|
|
|
* @return \Generator|Results\Crew |
50
|
|
|
*/ |
51
|
1 |
|
public function getCrew() |
52
|
|
|
{ |
53
|
1 |
|
if (!empty($this->data->crew)) |
54
|
|
|
{ |
55
|
1 |
|
foreach ($this->data->crew as $c) |
56
|
|
|
{ |
57
|
1 |
|
$crew = new Crew($this->tmdb, $c); |
58
|
1 |
|
yield $crew; |
59
|
|
|
} |
60
|
|
|
} |
61
|
1 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Cast |
65
|
|
|
* @return \Generator|Results\Cast |
66
|
|
|
*/ |
67
|
9 |
|
public function getCast() |
68
|
|
|
{ |
69
|
9 |
|
if (!empty($this->data->cast)) |
70
|
|
|
{ |
71
|
9 |
|
foreach ($this->data->cast as $c) |
72
|
|
|
{ |
73
|
9 |
|
$cast = new Cast($this->tmdb, $c); |
74
|
9 |
|
yield $cast; |
75
|
|
|
} |
76
|
|
|
} |
77
|
1 |
|
} |
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
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.