diff --git a/examples/movies/model/get.php b/examples/movies/model/get.php index add85015..2fb7610a 100644 --- a/examples/movies/model/get.php +++ b/examples/movies/model/get.php @@ -10,36 +10,49 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ - require_once('../../../vendor/autoload.php'); - require_once('../../../apikey.php'); +require_once('../../../vendor/autoload.php'); +require_once('../../../apikey.php'); - $token = new \Tmdb\ApiToken(TMDB_API_KEY); - $client = new \Tmdb\Client($token); +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); - $movie = \Tmdb\Model\Movie::load($client, 87421, array( - 'append_to_response' => 'casts,images' - )); +$append = new \Tmdb\Model\Movie\QueryParameter\AppendToResponse(array( + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::ALTERNATIVE_TITLES, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::CHANGES, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::CREDITS, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::IMAGES, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::KEYWORDS, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::LISTS, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::RELEASES, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::REVIEWS, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::SIMILAR_MOVIES, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::TRAILERS, + \Tmdb\Model\Movie\QueryParameter\AppendToResponse::TRANSLATIONS, +)); - echo $movie->getTitle() . "\n"; +$movie = \Tmdb\Model\Movie::load($client, 87421, array($append, $language)); - echo "Cast\n"; - foreach($movie->getCast() as $person) { - printf(" - %s as %s\n", $person->getName(), $person->getCharacter()); - } +echo $movie->getTitle() . "\n"; - foreach($movie->getCrew() as $person) { - printf(" - %s as %s\n", $person->getName(), $person->getJob()); - } +echo "Cast\n"; - echo "Images\n"; +foreach($movie->getCast() as $person) { + printf(" - %s as %s\n", $person->getName(), $person->getCharacter()); +} - foreach($movie->getImages() as $image) { - printf(" - %s\n", $image->getFilePath()); - } +foreach($movie->getCrew() as $person) { + printf(" - %s as %s\n", $person->getName(), $person->getJob()); +} - echo "Genres\n"; +echo "Images\n"; - foreach($movie->getGenres() as $genre) { - printf(" - %s\n", $genre->getName()); - } \ No newline at end of file +foreach($movie->getImages() as $image) { + printf(" - %s\n", $image->getFilePath()); +} + +echo "Genres\n"; + +foreach($movie->getGenres() as $genre) { + printf(" - %s\n", $genre->getName()); +} \ No newline at end of file diff --git a/lib/Tmdb/Client.php b/lib/Tmdb/Client.php index 26038dcd..445333e9 100644 --- a/lib/Tmdb/Client.php +++ b/lib/Tmdb/Client.php @@ -88,22 +88,22 @@ public function api($name) { switch($name) { case 'configuration': - /** @return Api\Configuration */ + /** @var Api\Configuration */ $api = new Api\Configuration($this); break; case 'authentication': - /** @return Api\Authentication */ + /** @var Api\Authentication */ $api = new Api\Authentication($this); break; case 'account': - /** @return Api\Account */ + /** @var Api\Account */ $api = new Api\Account($this); break; case 'movies': - /** @return Api\Movies */ + /** @var Api\Movies */ $api = new Api\Movies($this); break; diff --git a/lib/Tmdb/Model/AbstractModel.php b/lib/Tmdb/Model/AbstractModel.php index 38539920..664157b0 100644 --- a/lib/Tmdb/Model/AbstractModel.php +++ b/lib/Tmdb/Model/AbstractModel.php @@ -14,11 +14,14 @@ use Tmdb\Client; use Tmdb\Exception\RuntimeException; -use Tmdb\Model\Common\Genres; -use Tmdb\Model\Common\Images; -use Tmdb\Model\Common\People; -use Tmdb\Model\Movie\Cast as MovieCast; -use Tmdb\Model\Movie\Crew as MovieCrew; + +use Tmdb\Model\Common\Collection\Credits\Cast; +use Tmdb\Model\Common\Collection\Credits\Crew; +use Tmdb\Model\Common\Collection\Genres; +use Tmdb\Model\Common\Collection\Images; +use Tmdb\Model\Common\Collection\People; + +use Tmdb\Model\Common\QueryParameter\QueryParameterInterface; use Tmdb\Model\Person\CastMember; use Tmdb\Model\Person\CrewMember; @@ -97,6 +100,25 @@ public function hydrate(array $data = array()) return $this; } + /** + * Process query parameters + * + * @param array $parameters + * @return array + */ + protected function parseQueryParameters(array $parameters = array()) + { + foreach($parameters as $key => $candidate) { + if ($candidate instanceof QueryParameterInterface) { + unset($parameters[$key]); + + $parameters[$candidate->getKey()] = $candidate->getValue(); + } + } + + return $parameters; + } + /** * Collect all images from an `image` array ( containing e.g. posters / profiles etc. ) * @@ -154,7 +176,7 @@ protected function collectPeople($client, array $collection = array()) */ protected function collectCast($client, array $collection = array()) { - $people = new MovieCast(); + $people = new Cast(); foreach($collection as $item) { $person = CastMember::fromArray($client, $item); @@ -174,7 +196,7 @@ protected function collectCast($client, array $collection = array()) */ protected function collectCrew($client, array $collection = array()) { - $people = new MovieCrew(); + $people = new Crew(); foreach($collection as $item) { $person = CrewMember::fromArray($client, $item); diff --git a/lib/Tmdb/Model/Common/Changes.php b/lib/Tmdb/Model/Collection/Changes.php similarity index 83% rename from lib/Tmdb/Model/Common/Changes.php rename to lib/Tmdb/Model/Collection/Changes.php index 9fe564ac..e2922baa 100644 --- a/lib/Tmdb/Model/Common/Changes.php +++ b/lib/Tmdb/Model/Collection/Changes.php @@ -10,7 +10,9 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Common; +namespace Tmdb\Model\Common\Collection; + +use Tmdb\Model\Common\Collection; class Images extends Collection { diff --git a/lib/Tmdb/Model/Collection/Credits.php b/lib/Tmdb/Model/Collection/Credits.php new file mode 100644 index 00000000..9b90e63c --- /dev/null +++ b/lib/Tmdb/Model/Collection/Credits.php @@ -0,0 +1,66 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Collection; + +use Tmdb\Model\Collection\People\Cast; +use Tmdb\Model\Collection\People\Crew; + +class Credits { + /** + * @var Cast + */ + private $cast; + + /** + * @var Crew + */ + private $crew; + + /** + * @param \Tmdb\Model\Collection\People\Cast $cast + * @return $this + */ + public function setCast($cast) + { + $this->cast = $cast; + return $this; + } + + /** + * @return \Tmdb\Model\Collection\People\Cast + */ + public function getCast() + { + return $this->cast; + } + + /** + * @param \Tmdb\Model\Collection\People\Crew $crew + * @return $this + */ + public function setCrew($crew) + { + $this->crew = $crew; + return $this; + } + + /** + * @return \Tmdb\Model\Collection\People\Crew + */ + public function getCrew() + { + return $this->crew; + } + + +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Movie/Cast.php b/lib/Tmdb/Model/Collection/Credits/Cast.php similarity index 80% rename from lib/Tmdb/Model/Movie/Cast.php rename to lib/Tmdb/Model/Collection/Credits/Cast.php index 3556d9ee..9781fc23 100644 --- a/lib/Tmdb/Model/Movie/Cast.php +++ b/lib/Tmdb/Model/Collection/Credits/Cast.php @@ -10,9 +10,9 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Movie; +namespace Tmdb\Model\Collection\Credits; -use Tmdb\Model\Common\People\Cast as BaseCast; +use Tmdb\Model\Collection\People\Cast as BaseCast; class Cast extends BaseCast { diff --git a/lib/Tmdb/Model/Movie/Crew.php b/lib/Tmdb/Model/Collection/Credits/Crew.php similarity index 80% rename from lib/Tmdb/Model/Movie/Crew.php rename to lib/Tmdb/Model/Collection/Credits/Crew.php index 002b4b13..622f2d39 100644 --- a/lib/Tmdb/Model/Movie/Crew.php +++ b/lib/Tmdb/Model/Collection/Credits/Crew.php @@ -10,9 +10,9 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Movie; +namespace Tmdb\Model\Collection\Credits; -use Tmdb\Model\Common\People\Crew as BaseCrew; +use Tmdb\Model\Collection\People\Crew as BaseCrew; class Crew extends BaseCrew { diff --git a/lib/Tmdb/Model/Common/Genres.php b/lib/Tmdb/Model/Collection/Genres.php similarity index 91% rename from lib/Tmdb/Model/Common/Genres.php rename to lib/Tmdb/Model/Collection/Genres.php index e03258bb..49bccc5f 100644 --- a/lib/Tmdb/Model/Common/Genres.php +++ b/lib/Tmdb/Model/Collection/Genres.php @@ -10,8 +10,9 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Common; +namespace Tmdb\Model\Collection; +use Tmdb\Model\Common\Collection; use Tmdb\Model\Genre; class Genres extends Collection { @@ -19,7 +20,7 @@ class Genres extends Collection { /** * Returns all genres * - * @return array + * @return Genre[] */ public function getGenres() { diff --git a/lib/Tmdb/Model/Collection/Keywords.php b/lib/Tmdb/Model/Collection/Keywords.php new file mode 100644 index 00000000..7386c0d1 --- /dev/null +++ b/lib/Tmdb/Model/Collection/Keywords.php @@ -0,0 +1,56 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Common\Collection; + +use Tmdb\Model\Common\Collection; + +use Tmdb\Model\Keyword; + +class Keywords extends Collection { + + /** + * Returns all keywords + * + * @return array + */ + public function getKeywords() + { + return $this->data; + } + + /** + * Retrieve a keyword from the collection + * + * @param $id + * @return null + */ + public function getKeyword($id) { + foreach($this->data as $keyword) { + if ($id === $keyword->getId()) { + return $keyword; + } + } + + return null; + } + + /** + * Add a keyword to the collection + * + * @param Keyword $keyword + */ + public function addKeyword(Keyword $keyword) + { + $this->data[] = $keyword; + } +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Common/People.php b/lib/Tmdb/Model/Collection/People.php similarity index 90% rename from lib/Tmdb/Model/Common/People.php rename to lib/Tmdb/Model/Collection/People.php index 64794980..5b1349b7 100644 --- a/lib/Tmdb/Model/Common/People.php +++ b/lib/Tmdb/Model/Collection/People.php @@ -10,9 +10,11 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Common; +namespace Tmdb\Model\Collection; -use Tmdb\Model\Common\People\PersonInterface; +use Tmdb\Model\Common\Collection; + +use Tmdb\Model\Collection\People\PersonInterface; use Tmdb\Model\Person; class People extends Collection { diff --git a/lib/Tmdb/Model/Common/People/Cast.php b/lib/Tmdb/Model/Collection/People/Cast.php similarity index 90% rename from lib/Tmdb/Model/Common/People/Cast.php rename to lib/Tmdb/Model/Collection/People/Cast.php index e4c60a67..cc6b73d2 100644 --- a/lib/Tmdb/Model/Common/People/Cast.php +++ b/lib/Tmdb/Model/Collection/People/Cast.php @@ -10,9 +10,9 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Common\People; +namespace Tmdb\Model\Collection\People; -use Tmdb\Model\Common\People; +use Tmdb\Model\Collection\People; use Tmdb\Model\Person; class Cast extends People { diff --git a/lib/Tmdb/Model/Common/People/Crew.php b/lib/Tmdb/Model/Collection/People/Crew.php similarity index 90% rename from lib/Tmdb/Model/Common/People/Crew.php rename to lib/Tmdb/Model/Collection/People/Crew.php index 600c9fd2..c5f8fcd6 100644 --- a/lib/Tmdb/Model/Common/People/Crew.php +++ b/lib/Tmdb/Model/Collection/People/Crew.php @@ -10,9 +10,9 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Common\People; +namespace Tmdb\Model\Collection\People; -use Tmdb\Model\Common\People; +use Tmdb\Model\Collection\People; use Tmdb\Model\Person; class Crew extends People { diff --git a/lib/Tmdb/Model/Common/People/PersonInterface.php b/lib/Tmdb/Model/Collection/People/PersonInterface.php similarity index 91% rename from lib/Tmdb/Model/Common/People/PersonInterface.php rename to lib/Tmdb/Model/Collection/People/PersonInterface.php index 873660ed..73ad6f85 100644 --- a/lib/Tmdb/Model/Common/People/PersonInterface.php +++ b/lib/Tmdb/Model/Collection/People/PersonInterface.php @@ -10,7 +10,7 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Common\People; +namespace Tmdb\Model\Collection\People; interface PersonInterface { function getName(); diff --git a/lib/Tmdb/Model/Common/Collection.php b/lib/Tmdb/Model/Common/Collection.php index f58c8580..93e82ba0 100644 --- a/lib/Tmdb/Model/Common/Collection.php +++ b/lib/Tmdb/Model/Common/Collection.php @@ -15,6 +15,22 @@ use Guzzle\Common\Collection as GuzzleCollection; class Collection extends GuzzleCollection { + protected $data = array(); + + /** + * Allow adding objects to the collection + * + * @param $object + */ + public function addObject($object) + { + if (!is_object($object)) { + return; + } + + $this->add(null, $object); + } + /** * Allow support for adding objects * diff --git a/lib/Tmdb/Model/Common/Images.php b/lib/Tmdb/Model/Common/Collection/Images.php similarity index 93% rename from lib/Tmdb/Model/Common/Images.php rename to lib/Tmdb/Model/Common/Collection/Images.php index e42424f1..c2c33fc9 100644 --- a/lib/Tmdb/Model/Common/Images.php +++ b/lib/Tmdb/Model/Common/Collection/Images.php @@ -10,7 +10,9 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Common; +namespace Tmdb\Model\Common\Collection; + +use Tmdb\Model\Common\Collection; use Tmdb\Model\Image; diff --git a/lib/Tmdb/Model/Common/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Common/QueryParameter/AppendToResponse.php new file mode 100644 index 00000000..67744d70 --- /dev/null +++ b/lib/Tmdb/Model/Common/QueryParameter/AppendToResponse.php @@ -0,0 +1,25 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Common\QueryParameter; + +use Tmdb\Model\Common\QueryParameter\Type\CollectionToCommaSeperatedString; + +class AppendToResponse extends CollectionToCommaSeperatedString { + /** + * @return string + */ + public function getKey() + { + return 'append_to_response'; + } +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Common/QueryParameter/Language.php b/lib/Tmdb/Model/Common/QueryParameter/Language.php new file mode 100644 index 00000000..f5ea2d8b --- /dev/null +++ b/lib/Tmdb/Model/Common/QueryParameter/Language.php @@ -0,0 +1,39 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Common\QueryParameter; + +class Language implements QueryParameterInterface { + + private $language; + + public function __construct($language) + { + $this->language = $language; + } + + /** + * @return string + */ + public function getKey() + { + return 'language'; + } + + /** + * @return string + */ + public function getValue() + { + return $this->language; + } +} diff --git a/lib/Tmdb/Model/Common/QueryParameter/QueryParameterInterface.php b/lib/Tmdb/Model/Common/QueryParameter/QueryParameterInterface.php new file mode 100644 index 00000000..10ef4382 --- /dev/null +++ b/lib/Tmdb/Model/Common/QueryParameter/QueryParameterInterface.php @@ -0,0 +1,18 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Common\QueryParameter; + +interface QueryParameterInterface { + function getKey(); + function getValue(); +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Common/QueryParameter/Type/CollectionToCommaSeperatedString.php b/lib/Tmdb/Model/Common/QueryParameter/Type/CollectionToCommaSeperatedString.php new file mode 100644 index 00000000..623f7a09 --- /dev/null +++ b/lib/Tmdb/Model/Common/QueryParameter/Type/CollectionToCommaSeperatedString.php @@ -0,0 +1,45 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Common\QueryParameter\Type; + +use Tmdb\Model\Common\Collection; +use Tmdb\Model\Common\QueryParameter\QueryParameterInterface; + +abstract class CollectionToCommaSeperatedString extends Collection implements QueryParameterInterface { + /** + * @param array $collection + */ + public function __construct(array $collection = array()) + { + $i = 0; + + foreach($collection as $item) { + $this->add($i, $item); + + $i++; + } + } + + /** + * {@inheritdoc} + */ + abstract public function getKey(); + + /** + * {@inheritdoc} + */ + public function getValue() + { + return implode(',', $this->data); + } +} diff --git a/lib/Tmdb/Model/Genre.php b/lib/Tmdb/Model/Genre.php index d82b1c2e..6e0c8968 100644 --- a/lib/Tmdb/Model/Genre.php +++ b/lib/Tmdb/Model/Genre.php @@ -40,15 +40,15 @@ public static function fromArray(Client $client, array $data) } /** - * Load a person with the given identifier + * Load a genre with the given identifier * * @param Client $client * @param $id - * @param $options + * @param $parameters * @return $this */ - public static function load(Client $client, $id, array $options = array()) { - $data = $client->api('genres')->getGenre($id, $options); + public static function load(Client $client, $id, array $parameters = array()) { + $data = $client->api('genres')->getGenre($id, parent::parseQueryParameters($parameters)); return Genre::fromArray($client, $data); } diff --git a/lib/Tmdb/Model/Movie.php b/lib/Tmdb/Model/Movie.php index 5d80875a..b929b8f6 100644 --- a/lib/Tmdb/Model/Movie.php +++ b/lib/Tmdb/Model/Movie.php @@ -13,11 +13,18 @@ namespace Tmdb\Model; use Tmdb\Client; + use Tmdb\Model\Common\Collection; +use Tmdb\Model\Common\Collection\Images; + +use Tmdb\Model\Collection\Credits; +use Tmdb\Model\Collection\Credits\Cast; +use Tmdb\Model\Collection\Credits\Crew; + +use Tmdb\Model\Collection\Genres; +use Tmdb\Model\Collection\People; + use Tmdb\Model\Common\Country; -use Tmdb\Model\Common\Genres; -use Tmdb\Model\Common\Images; -use Tmdb\Model\Common\People; use Tmdb\Model\Common\SpokenLanguage; class Movie extends AbstractModel { @@ -25,6 +32,14 @@ class Movie extends AbstractModel { private $adult = false; private $backdropPath; private $belongsToCollection = null; + private $budget; + + /** + * Genres + * + * @var Common\Genres + */ + private $genres; private $homepage; private $id; private $imdbId; @@ -44,57 +59,64 @@ class Movie extends AbstractModel { private $voteAverage; private $voteCount; - /** - * Cast members - * - * @var Movie\Cast - */ - protected $cast; + protected $alternativeTitles; + protected $changes; /** - * Crew members + * Credits * - * @var + * @var Common\Collection\Credits */ - protected $crew; - - /** - * Genres - * - * @var Common\Genres - */ - protected $genres; + protected $credits; /** * Images * - * @var Common\Images + * @var Common\Collection\Images */ protected $images; - protected $changes; + protected $keywords; + protected $lists; + protected $releases; + protected $similarMovies; + protected $trailers; + protected $translations; + protected static $_properties = array( 'adult', - 'backdropPath', - 'belongsToCollection', + 'backdrop_path', + 'belongs_to_collection', + 'budget', + 'genres', 'homepage', 'id', - 'imdbId', - 'originalTitle', + 'imdb_id', + 'original_title', 'overview', 'popularity', - 'posterPath', - 'productionCompanies', - 'productionCountries', - 'releaseDate', + 'poster_path', + 'production_companies', + 'production_countries', + 'release_date', 'revenue', 'runtime', - 'spokenLanguages', + 'spoken_languages', 'status', 'tagline', 'title', - 'voteAverage', - 'voteCount', + 'vote_average', + 'vote_count', + 'alternative_titles', + 'changes', + 'credits', + 'images', + 'keywords', + 'lists', + 'releases', + 'similar_movies', + 'trailers', + 'translations', ); /** @@ -102,10 +124,12 @@ class Movie extends AbstractModel { */ public function __construct() { - $this->genres = new Common\Genres(); - $this->images = new Common\Images(); - $this->cast = new Movie\Cast(); - $this->crew = new People(); + $this->genres = new Common\Collection\Genres(); + $this->images = new Common\Collection\Images(); + $this->credits = new Common\Collection\Credits(); + + $this->credits->setCast(new Cast()); + $this->credits->setCrew(new Crew()); } /** @@ -122,7 +146,8 @@ public static function fromArray(Client $client, array $data) $casts = array(); - if (array_key_exists('alternative_titles', $casts)) { + if (array_key_exists('alternative_titles', $data)) { + $movie->setAlternativeTitles(parent::collectAlternativeTitles($client, $data['alternative_titles'])); } if (array_key_exists('casts', $data)) { @@ -177,11 +202,11 @@ public static function fromArray(Client $client, array $data) * * @param Client $client * @param $id - * @param $with + * @param $parameters * @return $this */ - public static function load(Client $client, $id, array $with = array()) { - $data = $client->api('movies')->getMovie($id, $with); + public static function load(Client $client, $id, array $parameters = array()) { + $data = $client->api('movies')->getMovie($id, parent::parseQueryParameters($parameters)); return Movie::fromArray($client, $data); } diff --git a/lib/Tmdb/Model/Movie/AlternativeTitle.php b/lib/Tmdb/Model/Movie/AlternativeTitle.php new file mode 100644 index 00000000..475b5e0a --- /dev/null +++ b/lib/Tmdb/Model/Movie/AlternativeTitle.php @@ -0,0 +1,93 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model; + +use Tmdb\Client; + +class AlternativeTitle extends AbstractModel { + + private $id; + private $name; + + protected static $_properties = array( + 'id', + 'name', + ); + + /** + * Convert an array to an hydrated object + * + * @param Client $client + * @param array $data + * @return $this + */ + public static function fromArray(Client $client, array $data) + { + $genre = new AlternativeTitle(); + //$genre->setClient($client); + + return $genre->hydrate($data); + } + + /** + * Load a person with the given identifier + * + * @param Client $client + * @param $id + * @param $options + * @return $this + */ + public static function load(Client $client, $id, array $options = array()) { + $data = $client->api('genres')->getGenre($id, $options); + + return Genre::fromArray($client, $data); + } + + /** + * @param mixed $id + * @return $this + */ + public function setId($id) + { + $this->id = (int) $id; + return $this; + } + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * @param mixed $name + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * @return mixed + */ + public function getName() + { + return $this->name; + } + + +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Movie/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Movie/QueryParameter/AppendToResponse.php new file mode 100644 index 00000000..6c76a06f --- /dev/null +++ b/lib/Tmdb/Model/Movie/QueryParameter/AppendToResponse.php @@ -0,0 +1,18 @@ +api('people')->getPerson($id, $with); + public static function load(Client $client, $id, array $parameters = array()) { + $data = $client->api('people')->getPerson($id, parent::parseQueryParameters($parameters)); return Person::fromArray($client, $data); } diff --git a/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php new file mode 100644 index 00000000..6ff5071b --- /dev/null +++ b/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php @@ -0,0 +1,10 @@ +