/** * @link http://help.themoviedb.org/kb/api/company-movies */ public function movies($language = null, $page = 1) { $db = \TMDB\Client::getInstance(); $movies = array(); $info = $db->info(self::$type, $this->id, 'movies', array('language' => $language, 'page' => $page)); foreach ($info->results as $index => $movie) { $movies[$movie->id] = new Movie($movie); } return $movies; }
/** * @link http://help.themoviedb.org/kb/api/person-images */ public function images($size = false) { $db = \TMDB\Client::getInstance(); $info = $db->info(self::$type, $this->id, 'images'); foreach ($info as $type => $images) { if (!is_array($images)) { continue; } foreach ($images as $index => $data) { if ($size) { $info->{$type}[$index]->file_path = $db->image_url(substr($type, 0, strlen($type) - 1), $size, $data->file_path); } } } return $info; }
/** * Get an image base method * @param unknown_type $type 'backdrop', 'poster', 'profile', 'logo', ... * @param unknown_type $size int or preset * @param unknown_type $random true or false * @param unknown_type $language optional language to return the image in */ public function image($type, $size = false, $random = false, $language = null) { $image = false; $typeset = $type . 's'; // multiple $path_key = $type . '_path'; if ($random) { $images = $this->images($language, false); if (count($images) > 1) { $index = rand(0, count($images->{$typeset}) - 1); $this->{$path_key} = $images->{$typeset}[$index]->file_path; } } if (isset($this->{$path_key})) { if ($size) { $db = \TMDB\Client::getInstance(); $image = $db->image_url($type, $size, $this->{$path_key}); } else { $image = $this->{$path_key}; } } return $image; }
public function testGetInstance() { $instance = \TMDB\Client::getInstance(); $this->assertInstanceOf("\\TMDB\\Client", $instance); $this->assertEmpty($instance->error); }