diff --git a/examples/people/model/get.php b/examples/people/model/get.php index 6224f7f3..2daf6501 100644 --- a/examples/people/model/get.php +++ b/examples/people/model/get.php @@ -16,4 +16,6 @@ $token = new \Tmdb\ApiToken(TMDB_API_KEY); $client = new \Tmdb\Client($token); -$person = \Tmdb\Model\Person::load($client, 287, array('append_to_response' => 'images')); +$peopleRepository = \Tmdb\Repository\PeopleRepository($client); + +var_dump($person); diff --git a/examples/tv/model/episode.php b/examples/tv/model/episode.php new file mode 100644 index 00000000..e58f7030 --- /dev/null +++ b/examples/tv/model/episode.php @@ -0,0 +1,22 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once('../../../vendor/autoload.php'); +require_once('../../../apikey.php'); + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$repository = new \Tmdb\Repository\TvEpisodeRepository($client); +$episode = $repository->load(1396, 2, 1); + +var_dump($episode); \ No newline at end of file diff --git a/examples/tv/model/season.php b/examples/tv/model/season.php new file mode 100644 index 00000000..cc51e365 --- /dev/null +++ b/examples/tv/model/season.php @@ -0,0 +1,22 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once('../../../vendor/autoload.php'); +require_once('../../../apikey.php'); + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$repository = new \Tmdb\Repository\TvSeasonRepository($client); +$season = $repository->load(1396, 2); + +var_dump($season); \ No newline at end of file diff --git a/examples/tv/model/show.php b/examples/tv/model/show.php new file mode 100644 index 00000000..6fb8039f --- /dev/null +++ b/examples/tv/model/show.php @@ -0,0 +1,24 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once('../../../vendor/autoload.php'); +require_once('../../../apikey.php'); + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$repository = new \Tmdb\Repository\TvRepository($client); +$tvShow = $repository->load(1396); + +printf('

%s

', $tvShow->getName()); + +var_dump($tvShow); \ No newline at end of file diff --git a/lib/Tmdb/Api/Tv.php b/lib/Tmdb/Api/Tv.php index 502f96ea..d0d10eb9 100644 --- a/lib/Tmdb/Api/Tv.php +++ b/lib/Tmdb/Api/Tv.php @@ -29,7 +29,8 @@ public function getTvshow($tvshow_id, array $options = array(), array $headers = } /** - * Get the cast & crew information about a TV series. Just like the website, we pull this information from the last season of the series. + * Get the cast & crew information about a TV series. + * Just like the website, we pull this information from the last season of the series. * * @param $tvshow_id * @param array $options @@ -66,4 +67,32 @@ public function getImages($tvshow_id, array $options = array(), array $headers = { return $this->get('tv/' . $tvshow_id . '/images', $options, $headers); } + + /** + * Get the list of popular TV shows. This list refreshes every day. + * + * @param array $options + * @param array $headers + * @return mixed + */ + public function getPopular(array $options = array(), array $headers = array()) + { + return $this->get('tv/popular', $options, $headers); + } + + /** + * Get the list of top rated TV shows. + * + * By default, this list will only include TV shows that have 2 or more votes. + * This list refreshes every day. + * + * @param array $options + * @param array $headers + * @return mixed + */ + public function getTopRated(array $options = array(), array $headers = array()) + { + return $this->get('tv/top_rated', $options, $headers); + } + } \ No newline at end of file diff --git a/lib/Tmdb/Api/TvEpisode.php b/lib/Tmdb/Api/TvEpisode.php index e419e5bc..74d0e0d7 100644 --- a/lib/Tmdb/Api/TvEpisode.php +++ b/lib/Tmdb/Api/TvEpisode.php @@ -12,8 +12,6 @@ */ namespace Tmdb\Api; -use Tmdb\Exception\NotImplementedException; - class TvEpisode extends AbstractApi { diff --git a/lib/Tmdb/Factory/CompanyFactory.php b/lib/Tmdb/Factory/CompanyFactory.php new file mode 100644 index 00000000..667d7123 --- /dev/null +++ b/lib/Tmdb/Factory/CompanyFactory.php @@ -0,0 +1,41 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Factory; + +use Tmdb\Model\Common\Collection; +use Tmdb\Model\Company; + +class CompanyFactory extends AbstractFactory +{ + /** + * {@inheritdoc} + */ + public static function create(array $data = array()) + { + return parent::hydrate(new Company(), $data); + } + + /** + * {@inheritdoc} + */ + public static function createCollection(array $data = array()) + { + $collection = new Collection(); + + foreach($data as $item) { + $collection->add(null, self::create($item)); + } + + return $collection; + } +} \ No newline at end of file diff --git a/lib/Tmdb/Factory/ImageFactory.php b/lib/Tmdb/Factory/ImageFactory.php index 44db57a6..10d9d4b0 100644 --- a/lib/Tmdb/Factory/ImageFactory.php +++ b/lib/Tmdb/Factory/ImageFactory.php @@ -67,6 +67,30 @@ public static function createCollectionFromMovie(array $data = array()) return self::createImageCollection($data); } + /** + * {@inheritdoc} + */ + public static function createCollectionFromTv(array $data = array()) + { + return self::createImageCollection($data); + } + + /** + * {@inheritdoc} + */ + public static function createCollectionFromTvSeason(array $data = array()) + { + return self::createImageCollection($data); + } + + /** + * {@inheritdoc} + */ + public static function createCollectionFromTvEpisode(array $data = array()) + { + return self::createImageCollection($data); + } + /** * {@inheritdoc} */ diff --git a/lib/Tmdb/Factory/MovieFactory.php b/lib/Tmdb/Factory/MovieFactory.php index a31bb229..14657bf1 100644 --- a/lib/Tmdb/Factory/MovieFactory.php +++ b/lib/Tmdb/Factory/MovieFactory.php @@ -17,6 +17,7 @@ use Tmdb\Factory\People\CrewFactory; use Tmdb\Model\Common\Collection; use Tmdb\Model\Common\Trailer\Youtube; +use Tmdb\Model\Common\Translation; use Tmdb\Model\Movie; class MovieFactory extends AbstractFactory { @@ -74,7 +75,7 @@ public static function create(array $data = array()) } if (array_key_exists('translations', $data)) { - $movie->setTranslations(GenericCollectionFactory::createCollection($data['translations']['translations'], new Movie\Translation())); + $movie->setTranslations(GenericCollectionFactory::createCollection($data['translations']['translations'], new Translation())); } if (array_key_exists('similar_movies', $data)) { diff --git a/lib/Tmdb/Factory/People/CastFactory.php b/lib/Tmdb/Factory/People/CastFactory.php index 7fe309c6..3932619d 100644 --- a/lib/Tmdb/Factory/People/CastFactory.php +++ b/lib/Tmdb/Factory/People/CastFactory.php @@ -19,20 +19,20 @@ class CastFactory extends PeopleFactory /** * {@inheritdoc} */ - public static function create(array $data = array()) + public static function create(array $data = array(), $person = null) { - return parent::create($data); + return parent::create($data, $person); } /** * {@inheritdoc} */ - public static function createCollection(array $data = array()) + public static function createCollection(array $data = array(), $person = null) { $collection = new Cast(); foreach($data as $item) { - $collection->add(null, parent::create($item)); + $collection->add(null, parent::create($item, $person)); } return $collection; diff --git a/lib/Tmdb/Factory/People/CrewFactory.php b/lib/Tmdb/Factory/People/CrewFactory.php index 16358744..1c857320 100644 --- a/lib/Tmdb/Factory/People/CrewFactory.php +++ b/lib/Tmdb/Factory/People/CrewFactory.php @@ -19,20 +19,20 @@ class CrewFactory extends PeopleFactory /** * {@inheritdoc} */ - public static function create(array $data = array()) + public static function create(array $data = array(), $person = null) { - return parent::create($data); + return parent::create($data, $person); } /** * {@inheritdoc} */ - public static function createCollection(array $data = array()) + public static function createCollection(array $data = array(), $person = null) { $collection = new Crew(); foreach($data as $item) { - $collection->add(null, parent::create($item)); + $collection->add(null, parent::create($item, $person)); } return $collection; diff --git a/lib/Tmdb/Factory/People/PeopleFactory.php b/lib/Tmdb/Factory/People/PeopleFactory.php index 4d5e290d..4cfebd89 100644 --- a/lib/Tmdb/Factory/People/PeopleFactory.php +++ b/lib/Tmdb/Factory/People/PeopleFactory.php @@ -13,31 +13,31 @@ namespace Tmdb\Factory\People; use Tmdb\Factory\AbstractFactory; +use Tmdb\Factory\ImageFactory; + use Tmdb\Model\Common\Collection; use Tmdb\Model\Person\CastMember; use Tmdb\Model\Person\CrewMember; use Tmdb\Model\Person; -use Tmdb\Factory\Common\ImageFactory; - class PeopleFactory extends AbstractFactory { /** * {@inheritdoc} */ - public static function create(array $data = array()) + public static function create(array $data = array(), Person\AbstractMember $person = null) { - $person = null; + if (!is_object($person)) { + if (array_key_exists('character', $data)) { + $person = new CastMember(); + } - if (array_key_exists('character', $data)) { - $person = new CastMember(); - } - - if (array_key_exists('job', $data)) { - $person = new CrewMember(); - } + if (array_key_exists('job', $data)) { + $person = new CrewMember(); + } - if (null === $person) { - $person = new Person(); + if (null === $person) { + $person = new Person(); + } } /** Images */ @@ -51,12 +51,12 @@ public static function create(array $data = array()) /** * {@inheritdoc} */ - public static function createCollection(array $data = array()) + public static function createCollection(array $data = array(), Person\AbstractMember $person = null) { $collection = new Collection(); foreach($data as $item) { - $collection->add(null, self::create($item)); + $collection->add(null, self::create($item, $person)); } return $collection; diff --git a/lib/Tmdb/Factory/TvEpisodeFactory.php b/lib/Tmdb/Factory/TvEpisodeFactory.php new file mode 100644 index 00000000..164870a6 --- /dev/null +++ b/lib/Tmdb/Factory/TvEpisodeFactory.php @@ -0,0 +1,75 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Factory; + +use Tmdb\Factory\Common\GenericCollectionFactory; +use Tmdb\Factory\People\CastFactory; +use Tmdb\Factory\People\CrewFactory; +use Tmdb\Model\Common\Collection; + +use Tmdb\Model\Tv\ExternalIds; +use Tmdb\Model\Tv\Person\CastMember; +use Tmdb\Model\Tv\Person\CrewMember; +use Tmdb\Model\Tv\Episode; + +class TvEpisodeFactory extends AbstractFactory { + /** + * {@inheritdoc} + */ + public static function create(array $data = array()) + { + if (!$data) { + return null; + } + + $tvEpisode = new Episode(); + + if (array_key_exists('credits', $data)) { + if (array_key_exists('cast', $data['credits'])) { + $tvEpisode->getCredits()->setCast(CastFactory::createCollection($data['credits']['cast'], new CastMember())); + } + + if (array_key_exists('crew', $data['credits'])) { + $tvEpisode->getCredits()->setCrew(CrewFactory::createCollection($data['credits']['crew'], new CrewMember())); + } + } + + /** External ids */ + if (array_key_exists('external_ids', $data)) { + $tvEpisode->setExternalIds( + parent::hydrate(new ExternalIds(), $data['external_ids']) + ); + } + + /** Images */ + if (array_key_exists('images', $data)) { + $tvEpisode->setImages(ImageFactory::createCollectionFromTv($data['images'])); + } + + return parent::hydrate($tvEpisode, $data); + } + + /** + * {@inheritdoc} + */ + public static function createCollection(array $data = array()) + { + $collection = new Collection(); + + foreach($data as $item) { + $collection->add(null, self::create($item)); + } + + return $collection; + } +} \ No newline at end of file diff --git a/lib/Tmdb/Factory/TvFactory.php b/lib/Tmdb/Factory/TvFactory.php new file mode 100644 index 00000000..70d9ed36 --- /dev/null +++ b/lib/Tmdb/Factory/TvFactory.php @@ -0,0 +1,95 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Factory; + +use Tmdb\Factory\Common\GenericCollectionFactory; +use Tmdb\Factory\People\CastFactory; +use Tmdb\Factory\People\CrewFactory; + +use Tmdb\Model\Common\Collection; + +use Tmdb\Model\Common\Translation; +use Tmdb\Model\Tv\ExternalIds; +use Tmdb\Model\Tv; + +class TvFactory extends AbstractFactory { + /** + * {@inheritdoc} + */ + public static function create(array $data = array()) + { + if (!$data) { + return null; + } + + $tvShow = new Tv(); + + if (array_key_exists('credits', $data)) { + if (array_key_exists('cast', $data['credits'])) { + $tvShow->getCredits()->setCast(CastFactory::createCollection($data['credits']['cast'], new Tv\Person\CastMember())); + } + + if (array_key_exists('crew', $data['credits'])) { + $tvShow->getCredits()->setCrew(CrewFactory::createCollection($data['credits']['crew'], new Tv\Person\CrewMember())); + } + } + + /** External ids */ + if (array_key_exists('external_ids', $data)) { + $tvShow->setExternalIds( + parent::hydrate(new ExternalIds(), $data['external_ids']) + ); + } + + /** Genres */ + if (array_key_exists('genres', $data)) { + $tvShow->setGenres(GenreFactory::createCollection($data['genres'])); + } + + /** Images */ + if (array_key_exists('images', $data)) { + $tvShow->setImages(ImageFactory::createCollectionFromTv($data['images'])); + } + + /** Translations */ + if (array_key_exists('translations', $data)) { + $tvShow->setTranslations(GenericCollectionFactory::createCollection($data['translations']['translations'], new Translation())); + } + + /** Seasons */ + if (array_key_exists('seasons', $data)) { + $tvShow->setSeasons(TvSeasonFactory::createCollection($data['seasons'])); + } + + /** Networks */ + if (array_key_exists('networks', $data)) { + $tvShow->setNetworks(GenericCollectionFactory::createCollection($data['networks'], new Tv\Network())); + } + + return parent::hydrate($tvShow, $data); + } + + /** + * {@inheritdoc} + */ + public static function createCollection(array $data = array()) + { + $collection = new Collection(); + + foreach($data as $item) { + $collection->add(null, self::create($item)); + } + + return $collection; + } +} diff --git a/lib/Tmdb/Factory/TvSeasonFactory.php b/lib/Tmdb/Factory/TvSeasonFactory.php new file mode 100644 index 00000000..02eae115 --- /dev/null +++ b/lib/Tmdb/Factory/TvSeasonFactory.php @@ -0,0 +1,81 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Factory; + +use Tmdb\Factory\Common\GenericCollectionFactory; +use Tmdb\Factory\People\CastFactory; +use Tmdb\Factory\People\CrewFactory; +use Tmdb\Model\Common\Collection; + +use Tmdb\Model\Tv\Episode; +use Tmdb\Model\Tv\ExternalIds; +use Tmdb\Model\Tv\Person\CastMember; +use Tmdb\Model\Tv\Person\CrewMember; +use Tmdb\Model\Tv\Season; + +class TvSeasonFactory extends AbstractFactory { + /** + * {@inheritdoc} + */ + public static function create(array $data = array()) + { + if (!$data) { + return null; + } + + $tvSeason = new Season(); + + if (array_key_exists('credits', $data)) { + if (array_key_exists('cast', $data['credits'])) { + $tvSeason->getCredits()->setCast(CastFactory::createCollection($data['credits']['cast'], new CastMember())); + } + + if (array_key_exists('crew', $data['credits'])) { + $tvSeason->getCredits()->setCrew(CrewFactory::createCollection($data['credits']['crew'], new CrewMember())); + } + } + + /** External ids */ + if (array_key_exists('external_ids', $data)) { + $tvSeason->setExternalIds( + parent::hydrate(new ExternalIds(), $data['external_ids']) + ); + } + + /** Images */ + if (array_key_exists('images', $data)) { + $tvSeason->setImages(ImageFactory::createCollectionFromTv($data['images'])); + } + + /** Episodes */ + if (array_key_exists('episodes', $data)) { + $tvSeason->setEpisodes(TvEpisodeFactory::createCollection($data['episodes'])); + } + + return parent::hydrate($tvSeason, $data); + } + + /** + * {@inheritdoc} + */ + public static function createCollection(array $data = array()) + { + $collection = new Collection(); + + foreach($data as $item) { + $collection->add(null, self::create($item)); + } + + return $collection; + } +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Movie/Translation.php b/lib/Tmdb/Model/Common/Translation.php similarity index 98% rename from lib/Tmdb/Model/Movie/Translation.php rename to lib/Tmdb/Model/Common/Translation.php index 495bcaf6..12d4c8b6 100644 --- a/lib/Tmdb/Model/Movie/Translation.php +++ b/lib/Tmdb/Model/Common/Translation.php @@ -10,7 +10,7 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Movie; +namespace Tmdb\Model\Common; use Tmdb\Model\AbstractModel; diff --git a/lib/Tmdb/Model/Genre.php b/lib/Tmdb/Model/Genre.php index 8c8cae55..3457ab6c 100644 --- a/lib/Tmdb/Model/Genre.php +++ b/lib/Tmdb/Model/Genre.php @@ -12,9 +12,6 @@ */ namespace Tmdb\Model; -use Tmdb\Client; -use Tmdb\Factory\GenreFactory; - class Genre extends AbstractModel { private $id; @@ -25,21 +22,6 @@ class Genre extends AbstractModel { '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 Genre($data['id']); - //$genre->setClient($client); - - return $genre->hydrate($data); - } - /** * @param mixed $id * @return $this diff --git a/lib/Tmdb/Model/Image.php b/lib/Tmdb/Model/Image.php index ac06ab8e..469f2acc 100644 --- a/lib/Tmdb/Model/Image.php +++ b/lib/Tmdb/Model/Image.php @@ -12,8 +12,6 @@ */ namespace Tmdb\Model; -use Tmdb\Client; - class Image extends AbstractModel { const FORMAT_POSTER = 'poster'; diff --git a/lib/Tmdb/Model/Person.php b/lib/Tmdb/Model/Person.php index cd0b5bef..7ca08cd6 100644 --- a/lib/Tmdb/Model/Person.php +++ b/lib/Tmdb/Model/Person.php @@ -12,8 +12,6 @@ */ namespace Tmdb\Model; -use Tmdb\Client; - use Tmdb\Model\Collection\Credits; use Tmdb\Model\Common\Collection; diff --git a/lib/Tmdb/Model/Person/CastMember.php b/lib/Tmdb/Model/Person/CastMember.php index 5ccfeb7b..95923be8 100644 --- a/lib/Tmdb/Model/Person/CastMember.php +++ b/lib/Tmdb/Model/Person/CastMember.php @@ -12,37 +12,23 @@ */ namespace Tmdb\Model\Person; -use Tmdb\Client; use Tmdb\Model\Collection\People\PersonInterface; class CastMember extends AbstractMember implements PersonInterface { private $character; private $order; + private $castId; public static $_properties = array( 'id', + 'cast_id', 'name', 'character', 'order', 'profile_path' ); - /** - * Convert an array to an hydrated object - * - * @param Client $client - * @param array $data - * @return $this - */ - public static function fromArray(Client $client, array $data) - { - $castMember = new CastMember(); - //$castMember->setClient($client); - - return $castMember->hydrate($data); - } - /** * @param mixed $character * @return $this @@ -79,5 +65,22 @@ public function getOrder() return $this->order; } + /** + * @param mixed $castId + * @return $this + */ + public function setCastId($castId) + { + $this->castId = $castId; + return $this; + } + + /** + * @return mixed + */ + public function getCastId() + { + return $this->castId; + } } \ No newline at end of file diff --git a/lib/Tmdb/Model/Person/CrewMember.php b/lib/Tmdb/Model/Person/CrewMember.php index 97859ced..a2c12f91 100644 --- a/lib/Tmdb/Model/Person/CrewMember.php +++ b/lib/Tmdb/Model/Person/CrewMember.php @@ -12,7 +12,6 @@ */ namespace Tmdb\Model\Person; -use Tmdb\Client; use Tmdb\Model\Collection\People\PersonInterface; class CrewMember extends AbstractMember implements PersonInterface { @@ -28,21 +27,6 @@ class CrewMember extends AbstractMember implements PersonInterface { 'profile_path' ); - /** - * Convert an array to an hydrated object - * - * @param Client $client - * @param array $data - * @return $this - */ - public static function fromArray(Client $client, array $data) - { - $crewMember = new CrewMember(); - //$crewMember->setClient($client); - - return $crewMember->hydrate($data); - } - /** * @param mixed $department * @return $this diff --git a/lib/Tmdb/Model/Query/AbstractQuery.php b/lib/Tmdb/Model/Query/AbstractQuery.php new file mode 100644 index 00000000..99124ef0 --- /dev/null +++ b/lib/Tmdb/Model/Query/AbstractQuery.php @@ -0,0 +1,43 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model; + +use Tmdb\Client; + +abstract class AbstractQuery extends AbstractModel { + + private $client; + + public function __construct(Client $client) + { + $this->setClient($client); + } + + /** + * @param mixed $client + * @return $this + */ + public function setClient($client) + { + $this->client = $client; + return $this; + } + + /** + * @return Client + */ + public function getClient() + { + return $this->client; + } +} diff --git a/lib/Tmdb/Model/Query/Changes.php b/lib/Tmdb/Model/Query/Changes.php index 3b622606..eddf1a51 100644 --- a/lib/Tmdb/Model/Query/Changes.php +++ b/lib/Tmdb/Model/Query/Changes.php @@ -12,21 +12,15 @@ */ namespace Tmdb\Model; -use Tmdb\Client; use Tmdb\Model\Changes\Change; use Tmdb\Model\Common\Collection; -class Changes extends AbstractModel { +class Changes extends AbstractQuery { private $from = null; private $to = null; private $page = null; - public function __construct(Client $client) - { - $this->setClient($client); - } - /** * Set the from parameter * @@ -74,7 +68,7 @@ public function execute() { $collection = new Collection(); - $response = $this->getClient()->api('changes')->getMovieChanges(array( + $response = $this->getClient()->getChangesApi()->getMovieChanges(array( 'from' => $this->from, 'to' => $this->to, 'page' => $this->page @@ -88,6 +82,4 @@ public function execute() return $collection; } - - //abstract public function getEntity(); -} \ No newline at end of file +} diff --git a/lib/Tmdb/Model/Query/Discover.php b/lib/Tmdb/Model/Query/Discover.php index 1a4db537..ccd852da 100644 --- a/lib/Tmdb/Model/Query/Discover.php +++ b/lib/Tmdb/Model/Query/Discover.php @@ -12,21 +12,16 @@ */ namespace Tmdb\Model\Query; -use Tmdb\Client; +use Tmdb\Model\AbstractQuery; use Tmdb\Model\Changes\Change; use Tmdb\Model\Common\Collection; -class Discover extends AbstractModel { +class Discover extends AbstractQuery { private $from = null; private $to = null; private $page = null; - public function __construct(Client $client) - { - $this->setClient($client); - } - /** * Set the from parameter * @@ -88,6 +83,4 @@ public function execute() return $collection; } - - //abstract public function getEntity(); -} \ No newline at end of file +} diff --git a/lib/Tmdb/Model/Tv.php b/lib/Tmdb/Model/Tv.php new file mode 100644 index 00000000..e51922af --- /dev/null +++ b/lib/Tmdb/Model/Tv.php @@ -0,0 +1,713 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model; + +use Tmdb\Model\Common\Collection; + +use Tmdb\Model\Collection\Credits; +use Tmdb\Model\Collection\Genres; +use Tmdb\Model\Collection\Images; +use Tmdb\Model\Collection\People; + +use Tmdb\Model\Common\Translation; +use Tmdb\Model\Tv\CastMember; +use Tmdb\Model\Tv\CrewMember; +use Tmdb\Model\Tv\ExternalIds; +use Tmdb\Model\Tv\Network; + +class Tv extends AbstractModel { + + /** + * @var Image + */ + private $backdropPath; + + /** + * @var Collection + */ + private $createdBy = null; + + /** + * @var array + */ + private $episodeRunTime; + + /** + * @var \DateTime + */ + private $firstAirDate; + + /** + * Genres + * + * @var Genres + */ + private $genres; + + /** + * @var string + */ + private $homepage; + + /** + * @var int + */ + private $id; + + /** + * @var boolean + */ + private $inProduction; + + /** + * @var array + */ + private $languages; + + /** + * @var \DateTime + */ + private $lastAirDate; + + /** + * @var string + */ + private $name; + + /** + * @var Network[] + */ + private $networks; + + /** + * @var integer + */ + private $numberOfEpisodes; + + /** + * @var integer + */ + private $numberOfSeasons; + + /** + * @var string + */ + private $originalName; + + /** + * @var Collection + */ + private $originCountry; + + /** + * @var string + */ + private $overview; + + /** + * @var float + */ + private $popularity; + + /** + * @var Image + */ + private $posterPath; + + /** + * @var Collection + */ + private $seasons; + + /** + * @var string + */ + private $status; + + /** + * @var float + */ + private $voteAverage; + + /** + * @var int + */ + private $voteCount; + + /** + * Credits + * + * @var Credits + */ + protected $credits; + + /** + * External Ids + * + * @var ExternalIds + */ + protected $externalIds; + + /** + * Images + * + * @var Images + */ + protected $images; + + /** + * @var Collection + */ + protected $translations; + + /** + * Properties that are available in the API + * + * These properties are hydrated by the ObjectHydrator, all the other properties are handled by the factory. + * + * @var array + */ + public static $_properties = array( + 'backdrop_path', + 'created_by', + 'episode_run_time', + 'first_air_date', + 'homepage', + 'id', + 'in_production', + 'languages', + 'last_air_date', + 'name', + //@todo remove networks + 'networks', + 'number_of_episodes', + 'number_of_seasons', + 'original_name', + 'origin_country', + 'overview', + 'popularity', + 'poster_path', + 'status', + 'vote_average', + 'vote_count', + ); + + /** + * Constructor + * + * Set all default collections + */ + public function __construct() + { + $this->createdBy = new Images(); + $this->episodeRunTime = new Collection(); + $this->genres = new Collection(); + $this->languages = new Collection(); + $this->networks = new Collection(); + $this->originCountry = new Collection(); + $this->seasons = new Collection(); + + $this->credits = new Credits(); + $this->externalIds = new ExternalIds(); + $this->images = new Images(); + $this->translations = new Collection(); + } + + /** + * @param \Tmdb\Model\Image $backdropPath + * @return $this + */ + public function setBackdropPath($backdropPath) + { + $this->backdropPath = $backdropPath; + return $this; + } + + /** + * @return \Tmdb\Model\Image + */ + public function getBackdropPath() + { + return $this->backdropPath; + } + + /** + * @param \Tmdb\Model\Common\Collection $createdBy + * @return $this + */ + public function setCreatedBy($createdBy) + { + $this->createdBy = $createdBy; + return $this; + } + + /** + * @return \Tmdb\Model\Common\Collection + */ + public function getCreatedBy() + { + return $this->createdBy; + } + + /** + * @param array $episodeRunTime + * @return $this + */ + public function setEpisodeRunTime($episodeRunTime) + { + $this->episodeRunTime = $episodeRunTime; + return $this; + } + + /** + * @return array + */ + public function getEpisodeRunTime() + { + return $this->episodeRunTime; + } + + /** + * @param \DateTime $firstAirDate + * @return $this + */ + public function setFirstAirDate($firstAirDate) + { + $this->firstAirDate = new \DateTime($firstAirDate); + return $this; + } + + /** + * @return \DateTime + */ + public function getFirstAirDate() + { + return $this->firstAirDate; + } + + /** + * @param \Tmdb\Model\Collection\Genres $genres + * @return $this + */ + public function setGenres($genres) + { + $this->genres = $genres; + return $this; + } + + /** + * @return \Tmdb\Model\Collection\Genres + */ + public function getGenres() + { + return $this->genres; + } + + /** + * @param string $homepage + * @return $this + */ + public function setHomepage($homepage) + { + $this->homepage = $homepage; + return $this; + } + + /** + * @return string + */ + public function getHomepage() + { + return $this->homepage; + } + + /** + * @param int $id + * @return $this + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param boolean $inProduction + * @return $this + */ + public function setInProduction($inProduction) + { + $this->inProduction = $inProduction; + return $this; + } + + /** + * @return boolean + */ + public function getInProduction() + { + return $this->inProduction; + } + + /** + * @param array $languages + * @return $this + */ + public function setLanguages($languages) + { + $this->languages = $languages; + return $this; + } + + /** + * @return array + */ + public function getLanguages() + { + return $this->languages; + } + + /** + * @param \DateTime $lastAirDate + * @return $this + */ + public function setLastAirDate($lastAirDate) + { + $this->lastAirDate = new \DateTime($lastAirDate); + return $this; + } + + /** + * @return \DateTime + */ + public function getLastAirDate() + { + return $this->lastAirDate; + } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param Collection $networks + * @return $this + */ + public function setNetworks($networks) + { + $this->networks = $networks; + return $this; + } + + /** + * @return Network[] + */ + public function getNetworks() + { + return $this->networks; + } + + /** + * @param int $numberOfEpisodes + * @return $this + */ + public function setNumberOfEpisodes($numberOfEpisodes) + { + $this->numberOfEpisodes = $numberOfEpisodes; + return $this; + } + + /** + * @return int + */ + public function getNumberOfEpisodes() + { + return $this->numberOfEpisodes; + } + + /** + * @param int $numberOfSeasons + * @return $this + */ + public function setNumberOfSeasons($numberOfSeasons) + { + $this->numberOfSeasons = $numberOfSeasons; + return $this; + } + + /** + * @return int + */ + public function getNumberOfSeasons() + { + return $this->numberOfSeasons; + } + + /** + * @param \Tmdb\Model\Common\Collection $originCountry + * @return $this + */ + public function setOriginCountry($originCountry) + { + $this->originCountry = $originCountry; + return $this; + } + + /** + * @return \Tmdb\Model\Common\Collection + */ + public function getOriginCountry() + { + return $this->originCountry; + } + + /** + * @param string $originalName + * @return $this + */ + public function setOriginalName($originalName) + { + $this->originalName = $originalName; + return $this; + } + + /** + * @return string + */ + public function getOriginalName() + { + return $this->originalName; + } + + /** + * @param string $overview + * @return $this + */ + public function setOverview($overview) + { + $this->overview = $overview; + return $this; + } + + /** + * @return string + */ + public function getOverview() + { + return $this->overview; + } + + /** + * @param float $popularity + * @return $this + */ + public function setPopularity($popularity) + { + $this->popularity = $popularity; + return $this; + } + + /** + * @return float + */ + public function getPopularity() + { + return $this->popularity; + } + + /** + * @param \Tmdb\Model\Image $posterPath + * @return $this + */ + public function setPosterPath($posterPath) + { + $this->posterPath = $posterPath; + return $this; + } + + /** + * @return \Tmdb\Model\Image + */ + public function getPosterPath() + { + return $this->posterPath; + } + + /** + * @param \Tmdb\Model\Common\Collection $seasons + * @return $this + */ + public function setSeasons($seasons) + { + $this->seasons = $seasons; + return $this; + } + + /** + * @return \Tmdb\Model\Common\Collection + */ + public function getSeasons() + { + return $this->seasons; + } + + /** + * @param string $status + * @return $this + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param float $voteAverage + * @return $this + */ + public function setVoteAverage($voteAverage) + { + $this->voteAverage = $voteAverage; + return $this; + } + + /** + * @return float + */ + public function getVoteAverage() + { + return $this->voteAverage; + } + + /** + * @param int $voteCount + * @return $this + */ + public function setVoteCount($voteCount) + { + $this->voteCount = $voteCount; + return $this; + } + + /** + * @return int + */ + public function getVoteCount() + { + return $this->voteCount; + } + + /** + * @param \Tmdb\Model\Common\Collection $translations + * @return $this + */ + public function setTranslations($translations) + { + $this->translations = $translations; + return $this; + } + + /** + * @return \Tmdb\Model\Common\Collection + */ + public function getTranslations() + { + return $this->translations; + } + + /** + * @param \Tmdb\Model\Collection\Images $images + * @return $this + */ + public function setImages($images) + { + $this->images = $images; + return $this; + } + + /** + * @return \Tmdb\Model\Collection\Images + */ + public function getImages() + { + return $this->images; + } + + /** + * @param \Tmdb\Model\ExternalIds $externalIds + * @return $this + */ + public function setExternalIds($externalIds) + { + $this->externalIds = $externalIds; + return $this; + } + + /** + * @return \Tmdb\Model\ExternalIds + */ + public function getExternalIds() + { + return $this->externalIds; + } + + /** + * @param \Tmdb\Model\Collection\Credits $credits + * @return $this + */ + public function setCredits($credits) + { + $this->credits = $credits; + return $this; + } + + /** + * @return \Tmdb\Model\Collection\Credits + */ + public function getCredits() + { + return $this->credits; + } + + +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Tv/Episode.php b/lib/Tmdb/Model/Tv/Episode.php new file mode 100644 index 00000000..f3c2ce86 --- /dev/null +++ b/lib/Tmdb/Model/Tv/Episode.php @@ -0,0 +1,359 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Tv; + +use Tmdb\Model\AbstractModel; +use Tmdb\Model\Collection\Credits; +use Tmdb\Model\Collection\Images; +use Tmdb\Model\Common\Collection; + +class Episode extends AbstractModel { + + /** + * @var \DateTime + */ + private $airDate; + + /** + * @var integer + */ + private $episodeNumber; + + /** + * @var string + */ + private $name; + + /** + * @var string + */ + private $overview; + + /** + * @var integer + */ + private $id; + + /** + * @var string + */ + private $productionCode; + + /** + * @var integer + */ + private $seasonNumber; + + /** + * @var string + */ + private $stillPath; + + /** + * @var float + */ + private $voteAverage; + + /** + * @var int + */ + private $voteCount; + + /** + * Credits + * + * @var Credits + */ + protected $credits; + + /** + * External Ids + * + * @var ExternalIds + */ + protected $externalIds; + + /** + * Images + * + * @var Images + */ + protected $images; + + + /** + * Properties that are available in the API + * + * These properties are hydrated by the ObjectHydrator, all the other properties are handled by the factory. + * + * @var array + */ + public static $_properties = array( + 'air_date', + 'episode_number', + 'name', + 'overview', + 'id', + 'production_code', + 'season_number', + 'still_path', + 'vote_average', + 'vote_count' + ); + + /** + * Constructor + */ + public function __construct() + { + $this->credits = new Credits(); + $this->externalIds = new ExternalIds(); + $this->images = new Images(); + } + + /** + * @param \DateTime $airDate + * @return $this + */ + public function setAirDate($airDate) + { + $this->airDate = new \DateTime($airDate); + return $this; + } + + /** + * @return \DateTime + */ + public function getAirDate() + { + return $this->airDate; + } + + /** + * @param int $episodeNumber + * @return $this + */ + public function setEpisodeNumber($episodeNumber) + { + $this->episodeNumber = $episodeNumber; + return $this; + } + + /** + * @return int + */ + public function getEpisodeNumber() + { + return $this->episodeNumber; + } + + /** + * @param int $id + * @return $this + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $overview + * @return $this + */ + public function setOverview($overview) + { + $this->overview = $overview; + return $this; + } + + /** + * @return string + */ + public function getOverview() + { + return $this->overview; + } + + /** + * @param string $productionCode + * @return $this + */ + public function setProductionCode($productionCode) + { + $this->productionCode = $productionCode; + return $this; + } + + /** + * @return string + */ + public function getProductionCode() + { + return $this->productionCode; + } + + /** + * @param int $seasonNumber + * @return $this + */ + public function setSeasonNumber($seasonNumber) + { + $this->seasonNumber = $seasonNumber; + return $this; + } + + /** + * @return int + */ + public function getSeasonNumber() + { + return $this->seasonNumber; + } + + /** + * @param string $stillPath + * @return $this + */ + public function setStillPath($stillPath) + { + $this->stillPath = $stillPath; + return $this; + } + + /** + * @return string + */ + public function getStillPath() + { + return $this->stillPath; + } + + /** + * @param float $voteAverage + * @return $this + */ + public function setVoteAverage($voteAverage) + { + $this->voteAverage = $voteAverage; + return $this; + } + + /** + * @return float + */ + public function getVoteAverage() + { + return $this->voteAverage; + } + + /** + * @param int $voteCount + * @return $this + */ + public function setVoteCount($voteCount) + { + $this->voteCount = $voteCount; + return $this; + } + + /** + * @return int + */ + public function getVoteCount() + { + return $this->voteCount; + } + + /** + * @param Credits $credits + * @return $this + */ + public function setCredits($credits) + { + $this->credits = $credits; + return $this; + } + + /** + * @return Credits + */ + public function getCredits() + { + return $this->credits; + } + + /** + * @param ExternalIds $externalIds + * @return $this + */ + public function setExternalIds($externalIds) + { + $this->externalIds = $externalIds; + return $this; + } + + /** + * @return ExternalIds + */ + public function getExternalIds() + { + return $this->externalIds; + } + + /** + * @param Images $images + * @return $this + */ + public function setImages($images) + { + $this->images = $images; + return $this; + } + + /** + * @return Images + */ + public function getImages() + { + return $this->images; + } + + +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Tv/Episode/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Tv/Episode/QueryParameter/AppendToResponse.php new file mode 100644 index 00000000..af847efb --- /dev/null +++ b/lib/Tmdb/Model/Tv/Episode/QueryParameter/AppendToResponse.php @@ -0,0 +1,21 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Tv\Episode\QueryParameter; + +use Tmdb\Model\Common\QueryParameter\AppendToResponse as BaseAppendToResponse; + +class AppendToResponse extends BaseAppendToResponse { + const CREDITS = 'credits'; + const EXTERNAL_IDS = 'external_ids'; + const IMAGES = 'images'; +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Tv/ExternalIds.php b/lib/Tmdb/Model/Tv/ExternalIds.php new file mode 100644 index 00000000..2bf2c5b0 --- /dev/null +++ b/lib/Tmdb/Model/Tv/ExternalIds.php @@ -0,0 +1,144 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Tv; + +use Tmdb\Model\AbstractModel; + +class ExternalIds extends AbstractModel { + + private $imdbId; + private $freebaseId; + private $freebaseMid; + private $id; + private $tvdbId; + private $tvrageId; + + public static $_properties = array( + 'imdb_id', + 'freebase_id', + 'freebase_mid', + 'id', + 'tvdb_id', + 'tvrage_id', + ); + + /** + * @param mixed $freebaseId + * @return $this + */ + public function setFreebaseId($freebaseId) + { + $this->freebaseId = $freebaseId; + return $this; + } + + /** + * @return mixed + */ + public function getFreebaseId() + { + return $this->freebaseId; + } + + /** + * @param mixed $freebaseMid + * @return $this + */ + public function setFreebaseMid($freebaseMid) + { + $this->freebaseMid = $freebaseMid; + return $this; + } + + /** + * @return mixed + */ + public function getFreebaseMid() + { + return $this->freebaseMid; + } + + /** + * @param mixed $id + * @return $this + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * @param mixed $imdbId + * @return $this + */ + public function setImdbId($imdbId) + { + $this->imdbId = $imdbId; + return $this; + } + + /** + * @return mixed + */ + public function getImdbId() + { + return $this->imdbId; + } + + /** + * @param mixed $tvdbId + * @return $this + */ + public function setTvdbId($tvdbId) + { + $this->tvdbId = $tvdbId; + return $this; + } + + /** + * @return mixed + */ + public function getTvdbId() + { + return $this->tvdbId; + } + + /** + * @param mixed $tvrageId + * @return $this + */ + public function setTvrageId($tvrageId) + { + $this->tvrageId = $tvrageId; + return $this; + } + + /** + * @return mixed + */ + public function getTvrageId() + { + return $this->tvrageId; + } + + +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Tv/Network.php b/lib/Tmdb/Model/Tv/Network.php new file mode 100644 index 00000000..4ec8c2d0 --- /dev/null +++ b/lib/Tmdb/Model/Tv/Network.php @@ -0,0 +1,78 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Tv; + +use Tmdb\Model\AbstractModel; + +class Network extends AbstractModel { + + /** + * @var integer + */ + private $id; + + /** + * @var string + */ + private $name; + + /** + * Properties that are available in the API + * + * These properties are hydrated by the ObjectHydrator, all the other properties are handled by the factory. + * + * @var array + */ + public static $_properties = array( + 'id', + 'name', + ); + + /** + * @param int $id + * @return $this + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Tv/Person/CastMember.php b/lib/Tmdb/Model/Tv/Person/CastMember.php new file mode 100644 index 00000000..5d5886c0 --- /dev/null +++ b/lib/Tmdb/Model/Tv/Person/CastMember.php @@ -0,0 +1,88 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Tv\Person; + +use Tmdb\Model\Person\AbstractMember; + +class CastMember extends AbstractMember { + + private $character; + private $order; + private $creditId; + + public static $_properties = array( + 'id', + 'credit_id', + 'name', + 'character', + 'order', + 'profile_path' + ); + + /** + * @param mixed $character + * @return $this + */ + public function setCharacter($character) + { + $this->character = $character; + return $this; + } + + /** + * @return mixed + */ + public function getCharacter() + { + return $this->character; + } + + /** + * @param mixed $order + * @return $this + */ + public function setOrder($order) + { + $this->order = (int) $order; + return $this; + } + + /** + * @return mixed + */ + public function getOrder() + { + return $this->order; + } + + /** + * @param mixed $creditId + * @return $this + */ + public function setCreditId($creditId) + { + $this->creditId = $creditId; + return $this; + } + + /** + * @return mixed + */ + public function getCreditId() + { + return $this->creditId; + } + + + +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Tv/CastMember.php b/lib/Tmdb/Model/Tv/Person/CrewMember.php similarity index 73% rename from lib/Tmdb/Model/Tv/CastMember.php rename to lib/Tmdb/Model/Tv/Person/CrewMember.php index a12c0975..47c7603a 100644 --- a/lib/Tmdb/Model/Tv/CastMember.php +++ b/lib/Tmdb/Model/Tv/Person/CrewMember.php @@ -10,10 +10,9 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model\Tv; +namespace Tmdb\Model\Tv\Person; -use Tmdb\Model\Person\CastMember as BaseCastMember; - -class CastMember extends BaseCastMember { +use Tmdb\Model\Person\CrewMember as BaseCrewMember; +class CrewMember extends BaseCrewMember { } \ No newline at end of file diff --git a/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php index 2712be00..e208141f 100644 --- a/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php +++ b/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php @@ -15,7 +15,8 @@ use Tmdb\Model\Common\QueryParameter\AppendToResponse as BaseAppendToResponse; class AppendToResponse extends BaseAppendToResponse { - const ALTERNATIVE_TITLES = 'alternative_titles'; - const EXTERNAL_IDS = 'external_ids'; - const IMAGES = 'images'; + const CREDITS = 'credits'; + const EXTERNAL_IDS = 'external_ids'; + const IMAGES = 'images'; + const TRANSLATIONS = 'translations'; } \ No newline at end of file diff --git a/lib/Tmdb/Model/Tv/Season.php b/lib/Tmdb/Model/Tv/Season.php new file mode 100644 index 00000000..f3a1742e --- /dev/null +++ b/lib/Tmdb/Model/Tv/Season.php @@ -0,0 +1,286 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Tv; + +use Tmdb\Model\AbstractModel; +use Tmdb\Model\Collection\Credits; +use Tmdb\Model\Collection\Images; +use Tmdb\Model\Common\Collection; + +class Season extends AbstractModel { + + /** + * @var \DateTime + */ + private $airDate; + + /** + * @var Episode[] + */ + private $episodes; + + /** + * @var string + */ + private $name; + + /** + * @var string + */ + private $overview; + + /** + * @var integer + */ + private $id; + + /** + * @var string + */ + private $posterPath; + + /** + * @var integer + */ + private $seasonNumber; + + /** + * Credits + * + * @var Credits + */ + protected $credits; + + /** + * External Ids + * + * @var ExternalIds + */ + protected $externalIds; + + /** + * Images + * + * @var Images + */ + protected $images; + + /** + * Properties that are available in the API + * + * These properties are hydrated by the ObjectHydrator, all the other properties are handled by the factory. + * + * @var array + */ + public static $_properties = array( + 'air_date', + 'name', + 'overview', + 'id', + 'poster_path', + 'season_number' + ); + + /** + * Constructor + */ + public function __construct() + { + $this->credits = new Credits(); + $this->externalIds = new ExternalIds(); + $this->images = new Images(); + $this->episodes = new Collection(); + } + + /** + * @param \DateTime $airDate + * @return $this + */ + public function setAirDate($airDate) + { + $this->airDate = new \DateTime($airDate); + return $this; + } + + /** + * @return \DateTime + */ + public function getAirDate() + { + return $this->airDate; + } + + /** + * @param Collection $episodes + * @return $this + */ + public function setEpisodes($episodes) + { + $this->episodes = $episodes; + return $this; + } + + /** + * @return \Tmdb\Model\Tv\Episode[] + */ + public function getEpisodes() + { + return $this->episodes; + } + + /** + * @param int $id + * @return $this + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $overview + * @return $this + */ + public function setOverview($overview) + { + $this->overview = $overview; + return $this; + } + + /** + * @return string + */ + public function getOverview() + { + return $this->overview; + } + + /** + * @param \Tmdb\Model\Tv\Image $posterPath + * @return $this + */ + public function setPosterPath($posterPath) + { + $this->posterPath = $posterPath; + return $this; + } + + /** + * @return \Tmdb\Model\Tv\Image + */ + public function getPosterPath() + { + return $this->posterPath; + } + + /** + * @param int $seasonNumber + * @return $this + */ + public function setSeasonNumber($seasonNumber) + { + $this->seasonNumber = $seasonNumber; + return $this; + } + + /** + * @return int + */ + public function getSeasonNumber() + { + return $this->seasonNumber; + } + + /** + * @param Collection $credits + * @return $this + */ + public function setCredits($credits) + { + $this->credits = $credits; + return $this; + } + + /** + * @return \Tmdb\Model\Collection\Credits + */ + public function getCredits() + { + return $this->credits; + } + + /** + * @param \Tmdb\Model\Tv\ExternalIds $externalIds + * @return $this + */ + public function setExternalIds($externalIds) + { + $this->externalIds = $externalIds; + return $this; + } + + /** + * @return \Tmdb\Model\Tv\ExternalIds + */ + public function getExternalIds() + { + return $this->externalIds; + } + + /** + * @param \Tmdb\Model\Collection\Images $images + * @return $this + */ + public function setImages($images) + { + $this->images = $images; + return $this; + } + + /** + * @return \Tmdb\Model\Collection\Images + */ + public function getImages() + { + return $this->images; + } + + +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Tv/Season/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Tv/Season/QueryParameter/AppendToResponse.php index 3ff0a0ac..d1cc3af5 100644 --- a/lib/Tmdb/Model/Tv/Season/QueryParameter/AppendToResponse.php +++ b/lib/Tmdb/Model/Tv/Season/QueryParameter/AppendToResponse.php @@ -12,7 +12,10 @@ */ namespace Tmdb\Model\Tv\Season\QueryParameter; -use Tmdb\Model\Tv\QueryParameter\AppendToResponse as BaseAppendToResponse; +use Tmdb\Model\Common\QueryParameter\AppendToResponse as BaseAppendToResponse; class AppendToResponse extends BaseAppendToResponse { + const CREDITS = 'credits'; + const EXTERNAL_IDS = 'external_ids'; + const IMAGES = 'images'; } \ No newline at end of file diff --git a/lib/Tmdb/Repository/AbstractRepository.php b/lib/Tmdb/Repository/AbstractRepository.php index 6222edb0..67ea4e7d 100644 --- a/lib/Tmdb/Repository/AbstractRepository.php +++ b/lib/Tmdb/Repository/AbstractRepository.php @@ -74,16 +74,6 @@ protected function parseHeaders(array $headers = array()) return $headers; } - /** - * Load the given identifier - * - * @param $id - * @param array $parameters Query parameters to pass to the request - * @param array $headers Headers to pass to the request - * @return mixed - */ - abstract public function load($id, array $parameters = array(), array $headers = array()); - /** * Return the API Class * diff --git a/lib/Tmdb/Repository/CompanyRepository.php b/lib/Tmdb/Repository/CompanyRepository.php new file mode 100644 index 00000000..274519e5 --- /dev/null +++ b/lib/Tmdb/Repository/CompanyRepository.php @@ -0,0 +1,71 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Repository; + +use Tmdb\Factory\CompanyFactory; +use Tmdb\Model\Common\Collection; +use Tmdb\Model\Company; + +class CompanyRepository extends AbstractRepository { + /** + * Load a company with the given identifier + * + * @param $id + * @param array $parameters + * @param array $headers + * @return Company + */ + public function load($id, array $parameters = array(), array $headers = array()) { + $data = $this->getApi()->getCompany($id, $this->parseQueryParameters($parameters), $this->parseHeaders($headers)); + + return CompanyFactory::create($data); + } + + /** + * If you obtained an person model which is not completely hydrated, you can use this function. + * + * @param Company $company + * @param array $parameters + * @param array $headers + * @return Company + */ + public function refresh(Company $company, array $parameters = array(), array $headers = array()) { + return $this->load($company->getId(), $parameters, $headers); + } + + /** + * Create an collection of an array + * + * @param $data + * @return Collection + */ + private function createCollection($data){ + $collection = new Collection(); + + foreach($data as $item) { + $collection->add(null, CompanyFactory::create($item)); + } + + return $collection; + } + + /** + * Return the related API class + * + * @return \Tmdb\Api\Companies + */ + public function getApi() + { + return $this->getClient()->getCompaniesApi(); + } +} \ No newline at end of file diff --git a/lib/Tmdb/Repository/ConfigurationRepository.php b/lib/Tmdb/Repository/ConfigurationRepository.php index 9494d152..f08cd545 100644 --- a/lib/Tmdb/Repository/ConfigurationRepository.php +++ b/lib/Tmdb/Repository/ConfigurationRepository.php @@ -18,31 +18,17 @@ class ConfigurationRepository extends AbstractRepository { /** - * Load a movie with the given identifier + * Load up TMDB Configuration * - * @param $id - * @param array $parameters * @param array $headers * @return Configuration */ - public function load($id = null, array $parameters = array(), array $headers = array()) { - $data = $this->getApi()->getConfiguration(); + public function load(array $headers = array()) { + $data = $this->getApi()->getConfiguration($headers); return ConfigurationFactory::create($data); } - /** - * If you obtained an movie model which is not completely hydrated, you can use this function. - * - * @todo store the previous given parameters so the same conditions apply to a refresh, and merge the new set - * - * @param array $parameters - * @return Configuration - */ - public function refresh(array $parameters = array(), array $headers = array()) { - return $this->load(null, $parameters); - } - /** * Return the Movies API Class * diff --git a/lib/Tmdb/Repository/TvEpisodeRepository.php b/lib/Tmdb/Repository/TvEpisodeRepository.php new file mode 100644 index 00000000..11cc4214 --- /dev/null +++ b/lib/Tmdb/Repository/TvEpisodeRepository.php @@ -0,0 +1,116 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Repository; + +use \RuntimeException; +use Tmdb\Factory\TvEpisodeFactory; +use Tmdb\Model\Common\Collection; + +use \Tmdb\Model\Tv\Episode\QueryParameter\AppendToResponse; + +use Tmdb\Model\Tv; +use Tmdb\Model\Tv\Season; +use Tmdb\Model\Tv\Episode; + +class TvEpisodeRepository extends AbstractRepository { + + /** + * Load a tv season with the given identifier + * + * If you want to optimize the result set/bandwidth you should define the AppendToResponse parameter + * + * @param $tvShow Tv|integer + * @param $season Season|integer + * @param $episode Episode|integer + * @param $parameters + * @param $headers + * @throws RuntimeException + * @return Season + */ + public function load($tvShow, $season, $episode, array $parameters = array(), array $headers = array()) + { + if ($tvShow instanceof Tv) { + $tvShow = $tvShow->getId(); + } + + if ($season instanceof Season) { + $season = $season->getId(); + } + + if ($episode instanceof Tv\Episode) { + $episode = $episode->getId(); + } + + if (null == $tvShow || null == $season || null == $episode) { + throw new RuntimeException('Not all required parameters to load an tv episode are present.'); + } + + if (empty($parameters)) { + $parameters = array( + new AppendToResponse(array( + AppendToResponse::CREDITS, + AppendToResponse::EXTERNAL_IDS, + AppendToResponse::IMAGES, + )) + ); + } + + $data = $this->getApi()->getEpisode($tvShow, $season, $episode, $this->parseQueryParameters($parameters), $this->parseHeaders($headers)); + + return TvEpisodeFactory::create($data); + } + + /** + * If you obtained an episode model which is not completely hydrated, you can use this function. + * + * @param Episode $episode + * @param array $parameters + * @param array $headers + * @return Season + */ + public function refresh(Episode $episode, array $parameters = array(), array $headers = array()) + { + return $this->load($episode->getId(), $parameters, $headers); + } + + /** + * Return the Seasons API Class + * + * @return \Tmdb\Api\TvEpisode + */ + public function getApi() + { + return $this->getClient()->getTvEpisodeApi(); + } + + /** + * Create an collection of an array + * + * @param $data + * @return Collection + */ + private function createCollection($data){ + $collection = new Collection(); + + if (array_key_exists('results', $data)) { + $data = $data['results']; + } + + foreach($data as $item) { + $collection->add(null, TvEpisodeFactory::create($item)); + } + + return $collection; + } + +} \ No newline at end of file diff --git a/lib/Tmdb/Repository/TvRepository.php b/lib/Tmdb/Repository/TvRepository.php new file mode 100644 index 00000000..e537603f --- /dev/null +++ b/lib/Tmdb/Repository/TvRepository.php @@ -0,0 +1,126 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Repository; + +use Tmdb\Factory\TvFactory; +use Tmdb\Model\Common\Collection; +use Tmdb\Model\Tv; + +use \Tmdb\Model\Tv\QueryParameter\AppendToResponse; + +class TvRepository extends AbstractRepository { + + /** + * Load a tv with the given identifier + * + * If you want to optimize the result set/bandwidth you should define the AppendToResponse parameter + * + * @param $id + * @param $parameters + * @param $headers + * @return Tv + */ + public function load($id, array $parameters = array(), array $headers = array()) + { + + if (empty($parameters)) { + $parameters = array( + new AppendToResponse(array( + AppendToResponse::CREDITS, + AppendToResponse::EXTERNAL_IDS, + AppendToResponse::IMAGES, + AppendToResponse::TRANSLATIONS + )) + ); + } + + $data = $this->getApi()->getTvshow($id, $this->parseQueryParameters($parameters), $this->parseHeaders($headers)); + + return TvFactory::create($data); + } + + /** + * If you obtained an tv model which is not completely hydrated, you can use this function. + * + * @todo store the previous given parameters so the same conditions apply to a refresh, and merge the new set + * + * @param Tv $tv + * @param array $parameters + * @param array $headers + * @return Tv + */ + public function refresh(Tv $tv, array $parameters = array(), array $headers = array()) + { + return $this->load($tv->getId(), $parameters, $headers); + } + + /** + * Return the Tvs API Class + * + * @return \Tmdb\Api\Tv + */ + public function getApi() + { + return $this->getClient()->getTvApi(); + } + + + /** + * Get the list of popular tvs on The Tv Database. This list refreshes every day. + * + * @param array $options + * @return Collection + */ + public function getPopular(array $options = array()) + { + return $this->createCollection( + $this->getApi()->getPopular($options) + ); + } + + /** + * Get the list of top rated tvs. By default, this list will only include tvs that have 10 or more votes. This list refreshes every day. + * + * @param array $options + * @return Collection + */ + public function getTopRated(array $options = array()) + { + return $this->createCollection( + $this->getApi()->getTopRated($options) + ); + } + + /** + * Create an collection of an array + * + * @todo Allow an array of Tv objects to pass ( custom collection ) + * + * @param $data + * @return Collection + */ + private function createCollection($data){ + $collection = new Collection(); + + if (array_key_exists('results', $data)) { + $data = $data['results']; + } + + foreach($data as $item) { + $collection->add(null, TvFactory::create($item)); + } + + return $collection; + } + +} \ No newline at end of file diff --git a/lib/Tmdb/Repository/TvSeasonRepository.php b/lib/Tmdb/Repository/TvSeasonRepository.php new file mode 100644 index 00000000..74d3c7d1 --- /dev/null +++ b/lib/Tmdb/Repository/TvSeasonRepository.php @@ -0,0 +1,112 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Repository; + +use \RuntimeException; + +use Tmdb\Factory\TvSeasonFactory; +use Tmdb\Model\Common\Collection; + +use \Tmdb\Model\Tv\Season\QueryParameter\AppendToResponse; +use Tmdb\Model\Tv\Season; +use Tmdb\Model\Tv; + +class TvSeasonRepository extends AbstractRepository { + + /** + * Load a tv season with the given identifier + * + * If you want to optimize the result set/bandwidth you should define the AppendToResponse parameter + * + * @param $tvShow + * @param $season + * @param $parameters + * @param $headers + * @throws RuntimeException + * @return Season + */ + public function load($tvShow, $season, array $parameters = array(), array $headers = array()) + { + if ($tvShow instanceof Tv) { + $tvShow = $tvShow->getId(); + } + + if ($season instanceof Season) { + $season = $season->getId(); + } + + if (null == $tvShow || null == $season) { + throw new RuntimeException('Not all required parameters to load an tv season are present.'); + } + + if (empty($parameters)) { + $parameters = array( + new AppendToResponse(array( + AppendToResponse::CREDITS, + AppendToResponse::EXTERNAL_IDS, + AppendToResponse::IMAGES, + )) + ); + } + + $data = $this->getApi()->getSeason($tvShow, $season, $this->parseQueryParameters($parameters), $this->parseHeaders($headers)); + + return TvSeasonFactory::create($data); + } + + /** + * If you obtained an season model which is not completely hydrated, you can use this function. + * + * @param Season $season + * @param array $parameters + * @param array $headers + * @return Season + */ + public function refresh(Season $season, array $parameters = array(), array $headers = array()) + { + return $this->load($season->getId(), $parameters, $headers); + } + + /** + * Return the Seasons API Class + * + * @return \Tmdb\Api\TvSeason + */ + public function getApi() + { + return $this->getClient()->getTvSeasonApi(); + } + + /** + * Create an collection of an array + * + * @todo Allow an array of Season objects to pass ( custom collection ) + * + * @param $data + * @return Collection + */ + private function createCollection($data){ + $collection = new Collection(); + + if (array_key_exists('results', $data)) { + $data = $data['results']; + } + + foreach($data as $item) { + $collection->add(null, TvSeasonFactory::create($item)); + } + + return $collection; + } + +} \ No newline at end of file