Passed
Branch master (465d67)
by vincent
02:35
created

People::getTVShowCrew()   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
 * @author Vincent Faliès <[email protected]>
12
 * @copyright Copyright (c) 2017
13
 */
14
15
namespace vfalies\tmdb\Items;
16
17
use vfalies\tmdb\Abstracts\Item;
18
use vfalies\tmdb\Interfaces\PeopleInterface;
19
use vfalies\tmdb\Traits\ElementTrait;
20
use vfalies\tmdb\lib\Guzzle\Client as HttpClient;
21
use vfalies\tmdb\Results\Image;
22
use vfalies\tmdb\Interfaces\TmdbInterface;
23
use vfalies\tmdb\Items\PeopleMovieCredit;
24
use vfalies\tmdb\Items\PeopleTVShowCredit;
25
26
/**
27
 * People class
28
 * @package Tmdb
29
 * @author Vincent Faliès <[email protected]>
30
 * @copyright Copyright (c) 2017
31
 */
32
class People extends Item implements PeopleInterface
33
{
34
35
    use ElementTrait;
36
37
    /**
38
     * Constructor
39
     * @param \vfalies\tmdb\Interfaces\TmdbInterface $tmdb
40
     * @param int $people_id
41
     * @param array $options
42
     * @throws Exception
43
     */
44 67
    public function __construct(TmdbInterface $tmdb, $people_id, array $options = array())
45
    {
46 67
        parent::__construct($tmdb, $people_id, $options, 'people');
47 66
    }
48
49
    /**
50
     * Adult
51
     * @return boolean
52
     */
53 2
    public function getAdult()
54
    {
55 2
        if (isset($this->data->adult))
56
        {
57 1
            return $this->data->adult;
58
        }
59 1
        return false;
60
    }
61
62
    /**
63
     * Alse Known as
64
     * @return array
65
     */
66 2
    public function getAlsoKnownAs()
67
    {
68 2
        if (isset($this->data->also_known_as))
69
        {
70 1
            return $this->data->also_known_as;
71
        }
72 1
        return [];
73
    }
74
75
    /**
76
     * Biography
77
     * @return string
78
     */
79 2
    public function getBiography()
80
    {
81 2
        if (isset($this->data->biography))
82
        {
83 1
            return $this->data->biography;
84
        }
85 1
        return '';
86
    }
87
88
    /**
89
     * Birthday
90
     * @return string
91
     */
92 2
    public function getBirthday()
93
    {
94 2
        if (isset($this->data->birthday))
95
        {
96 1
            return $this->data->birthday;
97
        }
98 1
        return '';
99
    }
100
101
    /**
102
     * Deathday
103
     * @return string
104
     */
105 2
    public function getDeathday()
106
    {
107 2
        if (isset($this->data->deathday))
108
        {
109 1
            return $this->data->deathday;
110
        }
111 1
        return '';
112
    }
113
114
    /**
115
     * Gender
116
     * @return int
117
     */
118 2
    public function getGender()
119
    {
120 2
        if (isset($this->data->gender))
121
        {
122 1
            return $this->data->gender;
123
        }
124 1
        return 0;
125
    }
126
127
    /**
128
     * Homepage
129
     * @return string
130
     */
131 2
    public function getHomepage()
132
    {
133 2
        if (isset($this->data->homepage))
134
        {
135 1
            return $this->data->homepage;
136
        }
137 1
        return '';
138
    }
139
140
    /**
141
     * Id
142
     * @return int
143
     */
144 3
    public function getId()
145
    {
146 3
        if (isset($this->data->id))
147
        {
148 2
            return $this->data->id;
149
        }
150 1
        return 0;
151
    }
152
153
    /**
154
     * Imdb Id
155
     * @return string
156
     */
157 2
    public function getImdbId()
158
    {
159 2
        if (isset($this->data->imdb_id))
160
        {
161 1
            return $this->data->imdb_id;
162
        }
163 1
        return '';
164
    }
165
166
    /**
167
     * Name
168
     * @return string
169
     */
170 2
    public function getName()
171
    {
172 2
        if (isset($this->data->name))
173
        {
174 1
            return $this->data->name;
175
        }
176 1
        return '';
177
    }
178
179
    /**
180
     * Place of birth
181
     * @return string
182
     */
183 2
    public function getPlaceOfBirth()
184
    {
185 2
        if (isset($this->data->place_of_birth))
186
        {
187 1
            return $this->data->place_of_birth;
188
        }
189 1
        return '';
190
    }
191
192
    /**
193
     * Popularity
194
     * @return int
195
     */
196 2
    public function getPopularity()
197
    {
198 2
        if (isset($this->data->popularity))
199
        {
200 1
            return $this->data->popularity;
201
        }
202 1
        return 0;
203
    }
204
205
    /**
206
     * Image profile path
207
     * @return string
208
     */
209 2
    public function getProfilePath()
210
    {
211 2
        if (isset($this->data->profile_path))
212
        {
213 1
            return $this->data->profile_path;
214
        }
215 1
        return '';
216
    }
217
218
    /**
219
     * Images Profiles
220
     * @return \Generator|Results\Image
221
     */
222 1
    public function getProfiles()
223
    {
224 1
        $data = $this->tmdb->sendRequest(new HttpClient(new \GuzzleHttp\Client()), '/person/' . (int) $this->id . '/images', null, $this->params);
225
226 1
        foreach ($data->profiles as $b)
227
        {
228 1
            $image = new Image($this->tmdb, $this->id, $b);
229 1
            yield $image;
230
        }
231 1
    }
232
233
    /**
234
     * Get movies cast
235
     * @return \Generator|Results\PeopleMovieCast
236
     */
237 9
    public function getMoviesCast()
238
    {
239 9
        $credit = new PeopleMovieCredit($this->tmdb, $this->id);
240 9
        return $credit->getCast();
241
    }
242
243
    /**
244
     * Get movies crew
245
     * @return \Generator|Results\PeopleMovieCast
246
     */
247 10
    public function getMoviesCrew()
248
    {
249 10
        $credit = new PeopleMovieCredit($this->tmdb, $this->id);
250 10
        return $credit->getCrew();
251
    }
252
253
254
    /**
255
     * Get TVShow cast
256
     * @return \Generator|Results\PeopleTVShowCast
257
     */
258 9
    public function getTVShowCast()
259
    {
260 9
        $credit = new PeopleTVShowCredit($this->tmdb, $this->id);
261 9
        return $credit->getCast();
262
    }
263
264
    /**
265
     * Get TVShow crew
266
     * @return \Generator|Results\PeopleTVShowCast
267
     */
268 10
    public function getTVShowCrew()
269
    {
270 10
        $credit = new PeopleTVShowCredit($this->tmdb, $this->id);
271 10
        return $credit->getCrew();
272
    }
273
}
274