| 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\Interfaces\Items\CompanyInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use vfalies\tmdb\lib\Guzzle\Client as HttpClient; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use vfalies\tmdb\Traits\ElementTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use vfalies\tmdb\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; | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      * Constructor | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |      * @param \vfalies\tmdb\Interfaces\TmdbInterface $tmdb | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |      * @param int $company_id | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |      * @param array $options | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 15 |  |     public function __construct(TmdbInterface $tmdb, $company_id, array $options = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 15 |  |         parent::__construct($tmdb, $company_id, $options, 'company'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 42 | 14 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |      * Company description | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 2 |  |     public function getDescription() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 2 |  |         if (isset($this->data->description)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 1 |  |             return $this->data->description; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 1 |  |         return ''; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |      * Company Head quarters | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 2 |  |     public function getHeadQuarters() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 2 |  |         if (isset($this->data->headquarters)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 1 |  |             return $this->data->headquarters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 1 |  |         return ''; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |      * Company Homepage | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 2 |  |     public function getHomePage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 2 |  |         if (isset($this->data->homepage)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 1 |  |             return $this->data->homepage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 1 |  |         return ''; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |      * Company Id | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |      * @return int | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 3 |  |     public function getId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 3 |  |         if (isset($this->data->id)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 2 |  |             return $this->data->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 1 |  |         return 0; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |      * Company image logo path | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 | 2 |  |     public function getLogoPath() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 2 |  |         if (isset($this->data->logo_path)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 1 |  |             return $this->data->logo_path; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 1 |  |         return ''; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |      * Company name | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 2 |  |     public function getName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 2 |  |         if (isset($this->data->name)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 | 1 |  |             return $this->data->name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 1 |  |         return ''; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 120 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |      * Company movies list | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |      * @return \Generator | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 1 |  |     public function getMovies() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 1 |  |         $data = $this->tmdb->sendRequest(new HttpClient(new \GuzzleHttp\Client()), '/company/' . (int) $this->id . '/movies', null, $this->params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 | 1 |  |         foreach ($data->results as $m) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 1 |  |             $movie = new \vfalies\tmdb\Results\Movie($this->tmdb, $m); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 | 1 |  |             yield $movie; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 135 | 1 |  |     } | 
            
                                                        
            
                                    
            
            
                | 136 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 137 |  |  |  |