From 80a168c31fd995c7d0c995aed9fa427c2d4fd362 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 26 Jan 2014 17:26:51 +0100 Subject: [PATCH] Cleaning up --- lib/Tmdb/Common/ObjectHydrator.php | 2 +- lib/Tmdb/Factory/People/CastFactory.php | 1 + lib/Tmdb/Factory/People/CrewFactory.php | 1 + lib/Tmdb/Model/Change.php | 2 - lib/Tmdb/Model/Collection.php | 2 +- lib/Tmdb/Model/Collection/Images.php | 4 +- lib/Tmdb/Model/Collection/Keywords.php | 1 - lib/Tmdb/Model/Collection/People.php | 1 - lib/Tmdb/Model/Collection/People/Cast.php | 2 +- lib/Tmdb/Model/Collection/People/Crew.php | 2 +- lib/Tmdb/Model/Common/DataCollector.php | 152 ------------------ .../QueryParameterInterface.php | 7 + lib/Tmdb/Model/Genre.php | 2 +- lib/Tmdb/Model/Movie.php | 20 +-- lib/Tmdb/Model/Movie/Release.php | 2 +- lib/Tmdb/Model/Person.php | 4 +- lib/Tmdb/Model/Person/AbstractMember.php | 12 +- lib/Tmdb/Model/Person/CastMember.php | 2 +- .../Query/Discover/DiscoverMoviesQuery.php | 2 +- lib/Tmdb/Model/Tv.php | 7 +- lib/Tmdb/Model/Tv/Episode.php | 1 - lib/Tmdb/Model/Tv/Person/CastMember.php | 2 +- lib/Tmdb/Repository/ChangesRepository.php | 3 +- lib/Tmdb/Repository/DiscoverRepository.php | 2 +- lib/Tmdb/Repository/TvRepository.php | 2 +- 25 files changed, 42 insertions(+), 196 deletions(-) delete mode 100644 lib/Tmdb/Model/Common/DataCollector.php diff --git a/lib/Tmdb/Common/ObjectHydrator.php b/lib/Tmdb/Common/ObjectHydrator.php index 01412a09..bdc387fe 100644 --- a/lib/Tmdb/Common/ObjectHydrator.php +++ b/lib/Tmdb/Common/ObjectHydrator.php @@ -21,7 +21,7 @@ class ObjectHydrator { * * @param AbstractModel $object * @param array $data - * @return $this + * @return AbstractModel * @throws RuntimeException */ public static function hydrate(AbstractModel $object, $data = array()) diff --git a/lib/Tmdb/Factory/People/CastFactory.php b/lib/Tmdb/Factory/People/CastFactory.php index 3932619d..b8a2e07d 100644 --- a/lib/Tmdb/Factory/People/CastFactory.php +++ b/lib/Tmdb/Factory/People/CastFactory.php @@ -26,6 +26,7 @@ public static function create(array $data = array(), $person = null) /** * {@inheritdoc} + * @param \Tmdb\Model\Tv\Person\CastMember $person */ public static function createCollection(array $data = array(), $person = null) { diff --git a/lib/Tmdb/Factory/People/CrewFactory.php b/lib/Tmdb/Factory/People/CrewFactory.php index 1c857320..545bf30b 100644 --- a/lib/Tmdb/Factory/People/CrewFactory.php +++ b/lib/Tmdb/Factory/People/CrewFactory.php @@ -26,6 +26,7 @@ public static function create(array $data = array(), $person = null) /** * {@inheritdoc} + * @param \Tmdb\Model\Tv\Person\CrewMember $person */ public static function createCollection(array $data = array(), $person = null) { diff --git a/lib/Tmdb/Model/Change.php b/lib/Tmdb/Model/Change.php index a184001b..93968c65 100644 --- a/lib/Tmdb/Model/Change.php +++ b/lib/Tmdb/Model/Change.php @@ -12,8 +12,6 @@ */ namespace Tmdb\Model; -use Tmdb\Client; - class Change extends AbstractModel { /** * @var integer diff --git a/lib/Tmdb/Model/Collection.php b/lib/Tmdb/Model/Collection.php index 3e5b1cfe..45f5d40e 100644 --- a/lib/Tmdb/Model/Collection.php +++ b/lib/Tmdb/Model/Collection.php @@ -163,7 +163,7 @@ public function getName() } /** - * @param \Tmdb\Model\Common\Collection $parts + * @param GenericCollection $parts * @return $this */ public function setParts($parts) diff --git a/lib/Tmdb/Model/Collection/Images.php b/lib/Tmdb/Model/Collection/Images.php index b8bd784c..bd1de85d 100644 --- a/lib/Tmdb/Model/Collection/Images.php +++ b/lib/Tmdb/Model/Collection/Images.php @@ -12,9 +12,7 @@ */ namespace Tmdb\Model\Collection; -use Tmdb\Factory\ImageFactory; use Tmdb\Model\Common\GenericCollection; - use Tmdb\Model\Filter\ImageFilter; use Tmdb\Model\Image; @@ -175,7 +173,7 @@ function($key, $value) use ($height) { /** * Return a single image that is rated highest * - * @return null|Image + * @return ImageFilter|null */ public function filterBestVotedImage() { diff --git a/lib/Tmdb/Model/Collection/Keywords.php b/lib/Tmdb/Model/Collection/Keywords.php index 5d6ddcea..6f9ec934 100644 --- a/lib/Tmdb/Model/Collection/Keywords.php +++ b/lib/Tmdb/Model/Collection/Keywords.php @@ -13,7 +13,6 @@ namespace Tmdb\Model\Common\Collection; use Tmdb\Model\Common\GenericCollection; - use Tmdb\Model\Keyword; class Keywords extends GenericCollection { diff --git a/lib/Tmdb/Model/Collection/People.php b/lib/Tmdb/Model/Collection/People.php index 786215e0..a7252e64 100644 --- a/lib/Tmdb/Model/Collection/People.php +++ b/lib/Tmdb/Model/Collection/People.php @@ -13,7 +13,6 @@ namespace Tmdb\Model\Collection; use Tmdb\Model\Common\GenericCollection; - use Tmdb\Model\Collection\People\PersonInterface; use Tmdb\Model\Person; diff --git a/lib/Tmdb/Model/Collection/People/Cast.php b/lib/Tmdb/Model/Collection/People/Cast.php index cc6b73d2..9da4c463 100644 --- a/lib/Tmdb/Model/Collection/People/Cast.php +++ b/lib/Tmdb/Model/Collection/People/Cast.php @@ -19,7 +19,7 @@ class Cast extends People { /** * Returns all people * - * @return People + * @return Person[] */ public function getCast() { diff --git a/lib/Tmdb/Model/Collection/People/Crew.php b/lib/Tmdb/Model/Collection/People/Crew.php index c5f8fcd6..a447b400 100644 --- a/lib/Tmdb/Model/Collection/People/Crew.php +++ b/lib/Tmdb/Model/Collection/People/Crew.php @@ -19,7 +19,7 @@ class Crew extends People { /** * Returns all people * - * @return People + * @return Person[] */ public function getCrew() { diff --git a/lib/Tmdb/Model/Common/DataCollector.php b/lib/Tmdb/Model/Common/DataCollector.php deleted file mode 100644 index 34d9c8f2..00000000 --- a/lib/Tmdb/Model/Common/DataCollector.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @copyright (c) 2013, Michael Roterman - * @version 0.0.1 - */ -namespace Tmdb\Model\Common; - -use Tmdb\Model\Collection\Genres; -use Tmdb\Model\Collection\People; -use Tmdb\Model\Common\Collection\Images; -use Tmdb\Model\Genre; -use Tmdb\Model\Image; -use Tmdb\Model\Person; - -class DataCollector { - - /** - * Collect all images from an `image` array ( containing e.g. posters / profiles etc. ) - * - * @param $client - * @param array $collection - * @return Image[] - */ - public function collectImages($client, array $collection = array()) - { - $images = new Images(); - - foreach($collection as $collectionName => $itemCollection) { - foreach($itemCollection as $item) { - if (!is_array($item)) { - continue; - } - - $image = Image::fromArray($client, $item); - - $image->setType(Image::getTypeFromCollectionName($collectionName)); - - $images->addImage($image); - } - } - - return $images; - } - - /** - * Collect all people from an array - * - * @param $client - * @param array $collection - * @return Person[] - */ - public function collectPeople($client, array $collection = array()) - { - $people = new People(); - - foreach($collection as $item) { - $person = Person::fromArray($client, $item); - - $people->addPerson($person); - } - - return $people; - } - - /** - * Collect cast - * - * @param $client - * @param array $collection - * @return CastMember[] - */ - public function collectCast($client, array $collection = array()) - { - $people = new Cast(); - - foreach($collection as $item) { - $person = CastMember::fromArray($client, $item); - - $people->addPerson($person); - } - - return $people; - } - - /** - * Collect crew - * - * @param $client - * @param array $collection - * @return CrewMember[] - */ - public function collectCrew($client, array $collection = array()) - { - $people = new Crew(); - - foreach($collection as $item) { - $person = CrewMember::fromArray($client, $item); - - $people->addPerson($person); - } - - return $people; - } - - /** - * Collect all genres from an array - * - * @param $client - * @param array $collection - * @return Genre[] - */ - public function collectGenres($client, array $collection = array()) - { - $genres = new Genres(); - - foreach($collection as $item) { - $genre = Genre::fromArray($client, $item); - $genres->addGenre($genre); - } - - return $genres; - } - - /** - * Collect all genres from an array - * - * @param $client - * @param array $collection - * @param object $object - * @return GenericCollection - */ - public function collectGenericCollection($client, array $collection = array(), $object) - { - $collectionObject = new GenericCollection(); - - foreach($collection as $item) { - $class = get_class($object); - $model = $class::fromArray($client, $item); - - $collectionObject->add(null, $model); - } - - return $collectionObject; - } -} \ No newline at end of file diff --git a/lib/Tmdb/Model/Common/QueryParameter/QueryParameterInterface.php b/lib/Tmdb/Model/Common/QueryParameter/QueryParameterInterface.php index 10ef4382..0be92642 100644 --- a/lib/Tmdb/Model/Common/QueryParameter/QueryParameterInterface.php +++ b/lib/Tmdb/Model/Common/QueryParameter/QueryParameterInterface.php @@ -13,6 +13,13 @@ namespace Tmdb\Model\Common\QueryParameter; interface QueryParameterInterface { + /** + * @return string + */ function getKey(); + + /** + * @return string + */ function getValue(); } \ No newline at end of file diff --git a/lib/Tmdb/Model/Genre.php b/lib/Tmdb/Model/Genre.php index 3457ab6c..84aaed24 100644 --- a/lib/Tmdb/Model/Genre.php +++ b/lib/Tmdb/Model/Genre.php @@ -33,7 +33,7 @@ public function setId($id) } /** - * @return mixed + * @return integer */ public function getId() { diff --git a/lib/Tmdb/Model/Movie.php b/lib/Tmdb/Model/Movie.php index 6713220b..23f494f7 100644 --- a/lib/Tmdb/Model/Movie.php +++ b/lib/Tmdb/Model/Movie.php @@ -13,20 +13,16 @@ namespace Tmdb\Model; use Tmdb\Model\Common\GenericCollection; - use Tmdb\Model\Collection\Credits; use Tmdb\Model\Collection\Genres; use Tmdb\Model\Collection\Images; use Tmdb\Model\Collection\People; - use Tmdb\Model\Common\Country; use Tmdb\Model\Common\SpokenLanguage; use Tmdb\Model\Common\Translation; use Tmdb\Model\Movie\AlternativeTitle; use Tmdb\Model\Movie\Keyword; use Tmdb\Model\Movie\Release; -use Tmdb\Model\Person\CastMember; -use Tmdb\Model\Person\CrewMember; class Movie extends AbstractModel { /** @@ -308,7 +304,7 @@ public function setBelongsToCollection($belongsToCollection) } /** - * @return null + * @return Collection|null */ public function getBelongsToCollection() { @@ -380,7 +376,7 @@ public function setId($id) } /** - * @return mixed + * @return integer */ public function getId() { @@ -470,7 +466,7 @@ public function setPopularity($popularity) } /** - * @return mixed + * @return double */ public function getPopularity() { @@ -542,7 +538,7 @@ public function setReleaseDate(\DateTime $releaseDate) } /** - * @return mixed + * @return \DateTime */ public function getReleaseDate() { @@ -560,7 +556,7 @@ public function setRevenue($revenue) } /** - * @return mixed + * @return integer */ public function getRevenue() { @@ -578,7 +574,7 @@ public function setRuntime($runtime) } /** - * @return mixed + * @return integer */ public function getRuntime() { @@ -668,7 +664,7 @@ public function setVoteAverage($voteAverage) } /** - * @return mixed + * @return double */ public function getVoteAverage() { @@ -686,7 +682,7 @@ public function setVoteCount($voteCount) } /** - * @return mixed + * @return integer */ public function getVoteCount() { diff --git a/lib/Tmdb/Model/Movie/Release.php b/lib/Tmdb/Model/Movie/Release.php index 2e48dc48..8c723f2d 100644 --- a/lib/Tmdb/Model/Movie/Release.php +++ b/lib/Tmdb/Model/Movie/Release.php @@ -74,7 +74,7 @@ public function setReleaseDate($releaseDate) } /** - * @return mixed + * @return \DateTime */ public function getReleaseDate() { diff --git a/lib/Tmdb/Model/Person.php b/lib/Tmdb/Model/Person.php index 44609f6f..9e540b18 100644 --- a/lib/Tmdb/Model/Person.php +++ b/lib/Tmdb/Model/Person.php @@ -13,10 +13,8 @@ namespace Tmdb\Model; use Tmdb\Model\Collection\Credits; - use Tmdb\Model\Common\GenericCollection; use Tmdb\Model\Collection\Images; - use Tmdb\Model\Collection\People\PersonInterface; use Tmdb\Model\Image\ProfileImage; @@ -228,7 +226,7 @@ public function getId() } /** - * @param mixed $images + * @param Images $images * @return $this */ public function setImages($images) diff --git a/lib/Tmdb/Model/Person/AbstractMember.php b/lib/Tmdb/Model/Person/AbstractMember.php index a78a675e..e403718c 100644 --- a/lib/Tmdb/Model/Person/AbstractMember.php +++ b/lib/Tmdb/Model/Person/AbstractMember.php @@ -13,12 +13,17 @@ namespace Tmdb\Model\Person; use Tmdb\Model\AbstractModel; +use Tmdb\Model\Image; abstract class AbstractMember extends AbstractModel { private $id; private $name; private $profilePath; + + /** + * @var Image + */ private $profile; public static $_properties = array( @@ -100,21 +105,22 @@ public function getOrder() } /** - * @param mixed $profile + * @param Image $profile * @return $this */ - public function setProfile($profile) + public function setProfile(Image $profile) { $this->profile = $profile; return $this; } /** - * @return mixed + * @return Image */ public function getProfile() { return $this->profile; } + } \ No newline at end of file diff --git a/lib/Tmdb/Model/Person/CastMember.php b/lib/Tmdb/Model/Person/CastMember.php index 95923be8..348423ff 100644 --- a/lib/Tmdb/Model/Person/CastMember.php +++ b/lib/Tmdb/Model/Person/CastMember.php @@ -58,7 +58,7 @@ public function setOrder($order) } /** - * @return mixed + * @return integer */ public function getOrder() { diff --git a/lib/Tmdb/Model/Query/Discover/DiscoverMoviesQuery.php b/lib/Tmdb/Model/Query/Discover/DiscoverMoviesQuery.php index 8bd2dcba..350a38ca 100644 --- a/lib/Tmdb/Model/Query/Discover/DiscoverMoviesQuery.php +++ b/lib/Tmdb/Model/Query/Discover/DiscoverMoviesQuery.php @@ -195,7 +195,7 @@ public function releaseDateGte($date) /** * The maximum release to include. * - * @param \DateTime|string $date + * @param \DateTime $date * @return $this */ public function releaseDateLte(\DateTime $date) diff --git a/lib/Tmdb/Model/Tv.php b/lib/Tmdb/Model/Tv.php index f8720818..eee62475 100644 --- a/lib/Tmdb/Model/Tv.php +++ b/lib/Tmdb/Model/Tv.php @@ -13,12 +13,9 @@ namespace Tmdb\Model; use Tmdb\Model\Common\GenericCollection; - use Tmdb\Model\Collection\Credits; use Tmdb\Model\Collection\Genres; use Tmdb\Model\Collection\Images; -use Tmdb\Model\Collection\People; - use Tmdb\Model\Tv\ExternalIds; use Tmdb\Model\Tv\Network; @@ -563,7 +560,7 @@ public function getPosterPath() } /** - * @param \Tmdb\Model\Common\Collection $seasons + * @param GenericCollection $seasons * @return $this */ public function setSeasons($seasons) @@ -635,7 +632,7 @@ public function getVoteCount() } /** - * @param \Tmdb\Model\Common\Collection $translations + * @param GenericCollection $translations * @return $this */ public function setTranslations($translations) diff --git a/lib/Tmdb/Model/Tv/Episode.php b/lib/Tmdb/Model/Tv/Episode.php index edbaae5a..b12f7f6c 100644 --- a/lib/Tmdb/Model/Tv/Episode.php +++ b/lib/Tmdb/Model/Tv/Episode.php @@ -15,7 +15,6 @@ use Tmdb\Model\AbstractModel; use Tmdb\Model\Collection\Credits; use Tmdb\Model\Collection\Images; -use Tmdb\Model\Common\GenericCollection; class Episode extends AbstractModel { diff --git a/lib/Tmdb/Model/Tv/Person/CastMember.php b/lib/Tmdb/Model/Tv/Person/CastMember.php index 5d5886c0..0f4500ea 100644 --- a/lib/Tmdb/Model/Tv/Person/CastMember.php +++ b/lib/Tmdb/Model/Tv/Person/CastMember.php @@ -58,7 +58,7 @@ public function setOrder($order) } /** - * @return mixed + * @return integer */ public function getOrder() { diff --git a/lib/Tmdb/Repository/ChangesRepository.php b/lib/Tmdb/Repository/ChangesRepository.php index 117bde1b..d3c606e4 100644 --- a/lib/Tmdb/Repository/ChangesRepository.php +++ b/lib/Tmdb/Repository/ChangesRepository.php @@ -15,7 +15,6 @@ use Tmdb\Factory\MovieFactory; use Tmdb\Factory\People\PeopleFactory; use Tmdb\Model\Collection\People; -use Tmdb\Model\Movie; use Tmdb\Model\Query\ChangesQuery; class ChangesRepository extends AbstractRepository { @@ -31,7 +30,7 @@ class ChangesRepository extends AbstractRepository { * * @param ChangesQuery $query * @param array $headers - * @return Movie[] + * @return \Tmdb\Model\Common\GenericCollection */ public function getMovieChanges(ChangesQuery $query, array $headers = array()) { $data = $this->getApi()->getMovieChanges($query->toArray(), $this->parseHeaders($headers)); diff --git a/lib/Tmdb/Repository/DiscoverRepository.php b/lib/Tmdb/Repository/DiscoverRepository.php index 4efde2cf..e33d183d 100644 --- a/lib/Tmdb/Repository/DiscoverRepository.php +++ b/lib/Tmdb/Repository/DiscoverRepository.php @@ -18,8 +18,8 @@ use Tmdb\Model\Movie; use Tmdb\Model\Query\Discover\DiscoverMoviesQuery; use Tmdb\Model\Query\Discover\DiscoverTvQuery; -use Tmdb\Model\Tv; +use Tmdb\Model\Tv; class DiscoverRepository extends AbstractRepository { /** * Discover movies by different types of data like average rating, number of votes, genres and certifications. diff --git a/lib/Tmdb/Repository/TvRepository.php b/lib/Tmdb/Repository/TvRepository.php index d465c8f1..03439903 100644 --- a/lib/Tmdb/Repository/TvRepository.php +++ b/lib/Tmdb/Repository/TvRepository.php @@ -24,7 +24,7 @@ class TvRepository extends AbstractRepository { * * If you want to optimize the result set/bandwidth you should define the AppendToResponse parameter * - * @param $id + * @param integer $id * @param $parameters * @param $headers * @return null|\Tmdb\Model\AbstractModel