From 608bd9332f931cf89b099772bd1dd67ef5885bc5 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 26 Jan 2014 16:55:52 +0100 Subject: [PATCH] Fixing some issues indicated by Scrutinizer --- lib/Tmdb/Api/Genres.php | 2 +- lib/Tmdb/Factory/AbstractFactory.php | 5 ++- lib/Tmdb/Factory/ImageFactory.php | 47 +++++++++++++++++---- lib/Tmdb/Model/Tv.php | 3 -- lib/Tmdb/Repository/AbstractRepository.php | 10 +++-- lib/Tmdb/Repository/TvEpisodeRepository.php | 2 +- lib/Tmdb/Repository/TvRepository.php | 2 +- 7 files changed, 51 insertions(+), 20 deletions(-) diff --git a/lib/Tmdb/Api/Genres.php b/lib/Tmdb/Api/Genres.php index b6e9a6bf..b4d4b359 100644 --- a/lib/Tmdb/Api/Genres.php +++ b/lib/Tmdb/Api/Genres.php @@ -25,7 +25,7 @@ class Genres */ public function getGenre($id, array $options = array(), array $headers = array()) { - $response = $this->getGenres(); + $response = $this->getGenres($options, $headers); if (array_key_exists('genres', $response)) { foreach($response['genres'] as $genre) { diff --git a/lib/Tmdb/Factory/AbstractFactory.php b/lib/Tmdb/Factory/AbstractFactory.php index 261acd91..10c145d3 100644 --- a/lib/Tmdb/Factory/AbstractFactory.php +++ b/lib/Tmdb/Factory/AbstractFactory.php @@ -13,6 +13,7 @@ namespace Tmdb\Factory; use Tmdb\Common\ObjectHydrator; +use Tmdb\Factory\Common\GenericCollectionFactory; use Tmdb\Model\AbstractModel; abstract class AbstractFactory { @@ -20,7 +21,7 @@ abstract class AbstractFactory { * Convert an array to an hydrated object * * @param array $data - * @return $this + * @return AbstractModel */ abstract public static function create(array $data = array()); @@ -28,7 +29,7 @@ abstract public static function create(array $data = array()); * Convert an array with an collection of items to an hydrated object collection * * @param array $data - * @return $this + * @return GenericCollectionFactory */ abstract public static function createCollection(array $data = array()); diff --git a/lib/Tmdb/Factory/ImageFactory.php b/lib/Tmdb/Factory/ImageFactory.php index 47c3eab3..b4a8c5fd 100644 --- a/lib/Tmdb/Factory/ImageFactory.php +++ b/lib/Tmdb/Factory/ImageFactory.php @@ -18,7 +18,11 @@ class ImageFactory extends AbstractFactory { /** - * {@inheritdoc} + * Convert an array to an hydrated object + * + * @param array $data + * @param string $key + * @return Image */ public static function create(array $data = array(), $key = null) { @@ -40,7 +44,7 @@ public static function create(array $data = array(), $key = null) * * @param $path * @param string $key - * @return \Tmdb\Model\Image + * @return Image */ public static function createFromPath($path, $key) { @@ -73,6 +77,10 @@ public static function getPossibleKeys() ); } + /** + * @param null $key + * @return Image|Image\BackdropImage|Image\LogoImage|Image\PosterImage|Image\ProfileImage|Image\StillImage + */ private function resolveImageType($key = null) { switch($key) { @@ -116,7 +124,10 @@ private function resolveImageType($key = null) } /** - * {@inheritdoc} + * Create generic collection + * + * @param array $data + * @return Images */ public static function createCollection(array $data = array()) { @@ -130,7 +141,10 @@ public static function createCollection(array $data = array()) } /** - * {@inheritdoc} + * Create full collection + * + * @param array $data + * @return Images */ public static function createImageCollection(array $data = array()) { @@ -150,7 +164,10 @@ public static function createImageCollection(array $data = array()) } /** - * {@inheritdoc} + * Create full movie collection + * + * @param array $data + * @return Images */ public static function createCollectionFromMovie(array $data = array()) { @@ -158,7 +175,10 @@ public static function createCollectionFromMovie(array $data = array()) } /** - * {@inheritdoc} + * Create full tv show collection + * + * @param array $data + * @return Images */ public static function createCollectionFromTv(array $data = array()) { @@ -166,7 +186,10 @@ public static function createCollectionFromTv(array $data = array()) } /** - * {@inheritdoc} + * Create full tv season collection + * + * @param array $data + * @return Images */ public static function createCollectionFromTvSeason(array $data = array()) { @@ -174,7 +197,10 @@ public static function createCollectionFromTvSeason(array $data = array()) } /** - * {@inheritdoc} + * Create full tv episode collection + * + * @param array $data + * @return Images */ public static function createCollectionFromTvEpisode(array $data = array()) { @@ -182,7 +208,10 @@ public static function createCollectionFromTvEpisode(array $data = array()) } /** - * {@inheritdoc} + * Create full people collection + * + * @param array $data + * @return Images */ public static function createCollectionFromPeople(array $data = array()) { diff --git a/lib/Tmdb/Model/Tv.php b/lib/Tmdb/Model/Tv.php index 3608b267..f8720818 100644 --- a/lib/Tmdb/Model/Tv.php +++ b/lib/Tmdb/Model/Tv.php @@ -19,9 +19,6 @@ 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; diff --git a/lib/Tmdb/Repository/AbstractRepository.php b/lib/Tmdb/Repository/AbstractRepository.php index 854e214b..a3e3d724 100644 --- a/lib/Tmdb/Repository/AbstractRepository.php +++ b/lib/Tmdb/Repository/AbstractRepository.php @@ -54,10 +54,14 @@ public function getClient() protected function parseQueryParameters(array $parameters = array()) { foreach($parameters as $key => $candidate) { - if ($candidate instanceof QueryParameterInterface) { - unset($parameters[$key]); + if (is_object($candidate)) { + $interfaces = class_implements($candidate); - $parameters[$candidate->getKey()] = $candidate->getValue(); + if (array_key_exists('Tmdb\Model\Common\QueryParameter\QueryParameterInterface', $interfaces)) { + unset($parameters[$key]); + + $parameters[$candidate->getKey()] = $candidate->getValue(); + } } } diff --git a/lib/Tmdb/Repository/TvEpisodeRepository.php b/lib/Tmdb/Repository/TvEpisodeRepository.php index 1fff9585..76cee657 100644 --- a/lib/Tmdb/Repository/TvEpisodeRepository.php +++ b/lib/Tmdb/Repository/TvEpisodeRepository.php @@ -16,7 +16,7 @@ use Tmdb\Factory\TvEpisodeFactory; use Tmdb\Model\Common\GenericCollection; -use \Tmdb\Model\Tv\Episode\QueryParameter\AppendToResponse; +use Tmdb\Model\Tv\Episode\QueryParameter\AppendToResponse; use Tmdb\Model\Tv; use Tmdb\Model\Tv\Season; diff --git a/lib/Tmdb/Repository/TvRepository.php b/lib/Tmdb/Repository/TvRepository.php index 1b1dec77..36bc6d29 100644 --- a/lib/Tmdb/Repository/TvRepository.php +++ b/lib/Tmdb/Repository/TvRepository.php @@ -16,7 +16,7 @@ use Tmdb\Model\Common\GenericCollection; use Tmdb\Model\Tv; -use \Tmdb\Model\Tv\QueryParameter\AppendToResponse; +use Tmdb\Model\Tv\QueryParameter\AppendToResponse; class TvRepository extends AbstractRepository {