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