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 | |||
| 15 | namespace VfacTmdb\Items; |
||
| 16 | |||
| 17 | use VfacTmdb\Abstracts\Item; |
||
| 18 | use VfacTmdb\Interfaces\Items\CompanyInterface; |
||
| 19 | use VfacTmdb\Results; |
||
| 20 | use VfacTmdb\Traits\ElementTrait; |
||
| 21 | use VfacTmdb\Interfaces\TmdbInterface; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Company class |
||
| 25 | * @package Tmdb |
||
| 26 | * @author Vincent Faliès <[email protected]> |
||
| 27 | * @copyright Copyright (c) 2017 |
||
| 28 | */ |
||
| 29 | class Company extends Item implements CompanyInterface |
||
| 30 | { |
||
| 31 | use ElementTrait; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 32 | |||
| 33 | /** |
||
| 34 | * Constructor |
||
| 35 | * @param TmdbInterface $tmdb |
||
| 36 | * @param int $company_id |
||
| 37 | * @param array $options |
||
| 38 | */ |
||
| 39 | 45 | public function __construct(TmdbInterface $tmdb, int $company_id, array $options = array()) |
|
| 40 | { |
||
| 41 | 45 | parent::__construct($tmdb, $company_id, $options, 'company'); |
|
| 42 | |||
| 43 | 42 | $this->setElementTrait($this->data); |
|
| 44 | 42 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * Company description |
||
| 48 | * @return string |
||
| 49 | */ |
||
| 50 | 6 | public function getDescription() : string |
|
| 51 | { |
||
| 52 | 6 | if (isset($this->data->description)) { |
|
| 53 | 3 | return $this->data->description; |
|
| 54 | } |
||
| 55 | 3 | return ''; |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Company Head quarters |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | 6 | public function getHeadQuarters() : string |
|
| 63 | { |
||
| 64 | 6 | if (isset($this->data->headquarters)) { |
|
| 65 | 3 | return $this->data->headquarters; |
|
| 66 | } |
||
| 67 | 3 | return ''; |
|
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Company Homepage |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | 6 | public function getHomePage() : string |
|
| 75 | { |
||
| 76 | 6 | if (isset($this->data->homepage)) { |
|
| 77 | 3 | return $this->data->homepage; |
|
| 78 | } |
||
| 79 | 3 | return ''; |
|
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Company Id |
||
| 84 | * @return int |
||
| 85 | */ |
||
| 86 | 9 | public function getId() : int |
|
| 87 | { |
||
| 88 | 9 | if (isset($this->data->id)) { |
|
| 89 | 6 | return $this->data->id; |
|
| 90 | } |
||
| 91 | 3 | return 0; |
|
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Company image logo path |
||
| 96 | * @return string |
||
| 97 | */ |
||
| 98 | 6 | public function getLogoPath() : string |
|
| 99 | { |
||
| 100 | 6 | if (isset($this->data->logo_path)) { |
|
| 101 | 3 | return $this->data->logo_path; |
|
| 102 | } |
||
| 103 | 3 | return ''; |
|
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Company name |
||
| 108 | * @return string |
||
| 109 | */ |
||
| 110 | 6 | public function getName() : string |
|
| 111 | { |
||
| 112 | 6 | if (isset($this->data->name)) { |
|
| 113 | 3 | return $this->data->name; |
|
| 114 | } |
||
| 115 | 3 | return ''; |
|
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Company movies list |
||
| 120 | * @return \Generator|Results\Movie |
||
| 121 | */ |
||
| 122 | 3 | public function getMovies() : \Generator |
|
| 123 | { |
||
| 124 | 3 | $params = []; |
|
| 125 | 3 | $this->tmdb->checkOptionLanguage($this->params, $params); |
|
| 126 | 3 | $data = $this->tmdb->getRequest('company/' . (int) $this->id . '/movies', $params); |
|
| 127 | |||
| 128 | 3 | foreach ($data->results as $m) { |
|
| 129 | 3 | $movie = new Results\Movie($this->tmdb, $m); |
|
| 130 | 3 | yield $movie; |
|
| 131 | } |
||
| 132 | 3 | } |
|
| 133 | } |
||
| 134 |