Passed
Branch release/1.5.0 (5f009d)
by vincent
05:05
created

People::getMoviesCrew()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of the Tmdb package.
5
 *
6
 * (c) Vincent Faliès <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
12
 * @author Vincent Faliès <[email protected]>
13
 * @copyright Copyright (c) 2017
14
 */
15
16
namespace vfalies\tmdb\Items;
17
18
use vfalies\tmdb\Abstracts\Item;
19
use vfalies\tmdb\Interfaces\PeopleInterface;
20
use vfalies\tmdb\Traits\ElementTrait;
21
use vfalies\tmdb\lib\Guzzle\Client as HttpClient;
22
use vfalies\tmdb\Results\Image;
23
use vfalies\tmdb\Interfaces\TmdbInterface;
24
use vfalies\tmdb\Items\PeopleMovieCredit;
25
use vfalies\tmdb\Items\PeopleTVShowCredit;
26
27
/**
28
 * People class
29
 * @package Tmdb
30
 * @author Vincent Faliès <[email protected]>
31
 * @copyright Copyright (c) 2017
32
 */
33
class People extends Item implements PeopleInterface
34
{
35
36
    use ElementTrait;
37
38
    /**
39
     * Constructor
40
     * @param \vfalies\tmdb\Interfaces\TmdbInterface $tmdb
41
     * @param int $people_id
42
     * @param array $options
43
     * @throws Exception
44
     */
45 67
    public function __construct(TmdbInterface $tmdb, $people_id, array $options = array())
46
    {
47 67
        parent::__construct($tmdb, $people_id, $options, 'people');
48 66
    }
49
50
    /**
51
     * Adult
52
     * @return boolean
53
     */
54 2
    public function getAdult()
55
    {
56 2
        if (isset($this->data->adult))
57
        {
58 1
            return $this->data->adult;
59
        }
60 1
        return false;
61
    }
62
63
    /**
64
     * Alse Known as
65
     * @return array
66
     */
67 2
    public function getAlsoKnownAs()
68
    {
69 2
        if (isset($this->data->also_known_as))
70
        {
71 1
            return $this->data->also_known_as;
72
        }
73 1
        return [];
74
    }
75
76
    /**
77
     * Biography
78
     * @return string
79
     */
80 2
    public function getBiography()
81
    {
82 2
        if (isset($this->data->biography))
83
        {
84 1
            return $this->data->biography;
85
        }
86 1
        return '';
87
    }
88
89
    /**
90
     * Birthday
91
     * @return string
92
     */
93 2
    public function getBirthday()
94
    {
95 2
        if (isset($this->data->birthday))
96
        {
97 1
            return $this->data->birthday;
98
        }
99 1
        return '';
100
    }
101
102
    /**
103
     * Deathday
104
     * @return string
105
     */
106 2
    public function getDeathday()
107
    {
108 2
        if (isset($this->data->deathday))
109
        {
110 1
            return $this->data->deathday;
111
        }
112 1
        return '';
113
    }
114
115
    /**
116
     * Gender
117
     * @return int
118
     */
119 2
    public function getGender()
120
    {
121 2
        if (isset($this->data->gender))
122
        {
123 1
            return $this->data->gender;
124
        }
125 1
        return 0;
126
    }
127
128
    /**
129
     * Homepage
130
     * @return string
131
     */
132 2
    public function getHomepage()
133
    {
134 2
        if (isset($this->data->homepage))
135
        {
136 1
            return $this->data->homepage;
137
        }
138 1
        return '';
139
    }
140
141
    /**
142
     * Id
143
     * @return int
144
     */
145 3
    public function getId()
146
    {
147 3
        if (isset($this->data->id))
148
        {
149 2
            return $this->data->id;
150
        }
151 1
        return 0;
152
    }
153
154
    /**
155
     * Imdb Id
156
     * @return string
157
     */
158 2
    public function getImdbId()
159
    {
160 2
        if (isset($this->data->imdb_id))
161
        {
162 1
            return $this->data->imdb_id;
163
        }
164 1
        return '';
165
    }
166
167
    /**
168
     * Name
169
     * @return string
170
     */
171 2
    public function getName()
172
    {
173 2
        if (isset($this->data->name))
174
        {
175 1
            return $this->data->name;
176
        }
177 1
        return '';
178
    }
179
180
    /**
181
     * Place of birth
182
     * @return string
183
     */
184 2
    public function getPlaceOfBirth()
185
    {
186 2
        if (isset($this->data->place_of_birth))
187
        {
188 1
            return $this->data->place_of_birth;
189
        }
190 1
        return '';
191
    }
192
193
    /**
194
     * Popularity
195
     * @return int
196
     */
197 2
    public function getPopularity()
198
    {
199 2
        if (isset($this->data->popularity))
200
        {
201 1
            return $this->data->popularity;
202
        }
203 1
        return 0;
204
    }
205
206
    /**
207
     * Image profile path
208
     * @return string
209
     */
210 2
    public function getProfilePath()
211
    {
212 2
        if (isset($this->data->profile_path))
213
        {
214 1
            return $this->data->profile_path;
215
        }
216 1
        return '';
217
    }
218
219
    /**
220
     * Images Profiles
221
     * @return \Generator|Results\Image
222
     */
223 1 View Code Duplication
    public function getProfiles()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
224
    {
225 1
        $data = $this->tmdb->sendRequest(new HttpClient(new \GuzzleHttp\Client()), '/person/'.(int) $this->id.'/images', null, $this->params);
226
227 1
        foreach ($data->profiles as $b)
228
        {
229 1
            $image = new Image($this->tmdb, $this->id, $b);
230 1
            yield $image;
231
        }
232 1
    }
233
234
    /**
235
     * Get movies cast
236
     * @return \Generator|Results\PeopleMovieCast
237
     */
238 9
    public function getMoviesCast()
239
    {
240 9
        $credit = new PeopleMovieCredit($this->tmdb, $this->id);
241 9
        return $credit->getCast();
242
    }
243
244
    /**
245
     * Get movies crew
246
     * @return \Generator|Results\PeopleMovieCast
247
     */
248 10
    public function getMoviesCrew()
249
    {
250 10
        $credit = new PeopleMovieCredit($this->tmdb, $this->id);
251 10
        return $credit->getCrew();
252
    }
253
254
255
    /**
256
     * Get TVShow cast
257
     * @return \Generator|Results\PeopleTVShowCast
258
     */
259 9
    public function getTVShowCast()
260
    {
261 9
        $credit = new PeopleTVShowCredit($this->tmdb, $this->id);
262 9
        return $credit->getCast();
263
    }
264
265
    /**
266
     * Get TVShow crew
267
     * @return \Generator|Results\PeopleTVShowCast
268
     */
269 10
    public function getTVShowCrew()
270
    {
271 10
        $credit = new PeopleTVShowCredit($this->tmdb, $this->id);
272 10
        return $credit->getCrew();
273
    }
274
}
275