From 3ce13f6863ecfc2eb282d086c26265fc508ad185 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 3 Nov 2013 13:59:29 +0100 Subject: [PATCH] Splitting up Tv into Tv, TvSeason and TvEpisode --- lib/Tmdb/Api/Tv.php | 82 -------------------------------------- lib/Tmdb/Api/TvEpisode.php | 75 ++++++++++++++++++++++++++++++++++ lib/Tmdb/Api/TvSeason.php | 45 +++++++++++++++++++++ lib/Tmdb/Client.php | 12 +++++- 4 files changed, 130 insertions(+), 84 deletions(-) create mode 100644 lib/Tmdb/Api/TvEpisode.php create mode 100644 lib/Tmdb/Api/TvSeason.php diff --git a/lib/Tmdb/Api/Tv.php b/lib/Tmdb/Api/Tv.php index 8d213269..12d88555 100644 --- a/lib/Tmdb/Api/Tv.php +++ b/lib/Tmdb/Api/Tv.php @@ -64,86 +64,4 @@ public function getImages($tvshow_id, array $options = array()) { return $this->get('tv/' . $tvshow_id . '/images', $options); } - - /** - * Get the primary information about a TV season by its season number. - * - * @param $tvshow_id - * @param $season_number - * @param array $options - * @return mixed - */ - public function getSeason($tvshow_id, $season_number, array $options = array()) - { - return $this->get(sprintf('tv/%s/season/%s', $tvshow_id, $season_number), $options); - } - - /** - * Get the external ids that we have stored for a TV season by season number. - * - * @param $tvshow_id - * @param $season_number - * @param array $options - * @return mixed - */ - public function getSeasonExternalIds($tvshow_id, $season_number, array $options = array()) - { - return $this->get(sprintf('tv/%s/season/%s/external_ids', $tvshow_id, $season_number), $options); - } - - /** - * Get the primary information about a TV episode by combination of a season and episode number. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $options - * @return mixed - */ - public function getEpisode($tvshow_id, $season_number, $episode_number, array $options = array()) - { - return $this->get(sprintf('tv/%s/season/%s/episode/%s', $tvshow_id, $season_number,$episode_number), $options); - } - - /** - * Get the TV episode credits by combination of season and episode number. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $options - * @return mixed - */ - public function getEpisodeCredits($tvshow_id, $season_number, $episode_number, array $options = array()) - { - return $this->get(sprintf('tv/%s/season/%s/episode/%s/credits', $tvshow_id, $season_number,$episode_number), $options); - } - - /** - * Get the external ids for a TV episode by comabination of a season and episode number. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $options - * @return mixed - */ - public function getEpisodeExternalIds($tvshow_id, $season_number, $episode_number, array $options = array()) - { - return $this->get(sprintf('tv/%s/season/%s/episode/%s/external_ids', $tvshow_id, $season_number,$episode_number), $options); - } - - /** - * Get the images (episode stills) for a TV episode by combination of a season and episode number. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $options - * @return mixed - */ - public function getEpisodeImages($tvshow_id, $season_number, $episode_number, array $options = array()) - { - return $this->get(sprintf('tv/%s/season/%s/episode/%s/images', $tvshow_id, $season_number,$episode_number), $options); - } } \ No newline at end of file diff --git a/lib/Tmdb/Api/TvEpisode.php b/lib/Tmdb/Api/TvEpisode.php new file mode 100644 index 00000000..fe97c386 --- /dev/null +++ b/lib/Tmdb/Api/TvEpisode.php @@ -0,0 +1,75 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Api; + +use Tmdb\Exception\NotImplementedException; + +class TvEpisode + extends AbstractApi +{ + /** + * Get the primary information about a TV episode by combination of a season and episode number. + * + * @param $tvshow_id + * @param $season_number + * @param $episode_number + * @param array $options + * @return mixed + */ + public function getEpisode($tvshow_id, $season_number, $episode_number, array $options = array()) + { + return $this->get(sprintf('tv/%s/season/%s/episode/%s', $tvshow_id, $season_number,$episode_number), $options); + } + + /** + * Get the TV episode credits by combination of season and episode number. + * + * @param $tvshow_id + * @param $season_number + * @param $episode_number + * @param array $options + * @return mixed + */ + public function getEpisodeCredits($tvshow_id, $season_number, $episode_number, array $options = array()) + { + return $this->get(sprintf('tv/%s/season/%s/episode/%s/credits', $tvshow_id, $season_number,$episode_number), $options); + } + + /** + * Get the external ids for a TV episode by comabination of a season and episode number. + * + * @param $tvshow_id + * @param $season_number + * @param $episode_number + * @param array $options + * @return mixed + */ + public function getEpisodeExternalIds($tvshow_id, $season_number, $episode_number, array $options = array()) + { + return $this->get(sprintf('tv/%s/season/%s/episode/%s/external_ids', $tvshow_id, $season_number,$episode_number), $options); + } + + /** + * Get the images (episode stills) for a TV episode by combination of a season and episode number. + * + * @param $tvshow_id + * @param $season_number + * @param $episode_number + * @param array $options + * @return mixed + */ + public function getEpisodeImages($tvshow_id, $season_number, $episode_number, array $options = array()) + { + return $this->get(sprintf('tv/%s/season/%s/episode/%s/images', $tvshow_id, $season_number,$episode_number), $options); + } +} \ No newline at end of file diff --git a/lib/Tmdb/Api/TvSeason.php b/lib/Tmdb/Api/TvSeason.php new file mode 100644 index 00000000..db0943cd --- /dev/null +++ b/lib/Tmdb/Api/TvSeason.php @@ -0,0 +1,45 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Api; + +use Tmdb\Exception\NotImplementedException; + +class TvSeason + extends AbstractApi +{ + /** + * Get the primary information about a TV season by its season number. + * + * @param $tvshow_id + * @param $season_number + * @param array $options + * @return mixed + */ + public function getSeason($tvshow_id, $season_number, array $options = array()) + { + return $this->get(sprintf('tv/%s/season/%s', $tvshow_id, $season_number), $options); + } + + /** + * Get the external ids that we have stored for a TV season by season number. + * + * @param $tvshow_id + * @param $season_number + * @param array $options + * @return mixed + */ + public function getSeasonExternalIds($tvshow_id, $season_number, array $options = array()) + { + return $this->get(sprintf('tv/%s/season/%s/external_ids', $tvshow_id, $season_number), $options); + } +} \ No newline at end of file diff --git a/lib/Tmdb/Client.php b/lib/Tmdb/Client.php index 445333e9..686bf872 100644 --- a/lib/Tmdb/Client.php +++ b/lib/Tmdb/Client.php @@ -113,12 +113,20 @@ public function api($name) break; case 'tv': - case 'tvseasons': - case 'tvepisodes': /** @return Api\Tv */ $api = new Api\Tv($this); break; + case 'tvseason': + /** @return Api\TvSeason */ + $api = new Api\TvSeason($this); + break; + + case 'tvepisode': + /** @return Api\TvEpisode */ + $api = new Api\TvEpisode($this); + break; + case 'people': /** @return Api\People */ $api = new Api\People($this);