From dc09c779a38dd630af29ac4bb4a49e76a2a28c9d Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 23 Mar 2014 16:53:11 +0100 Subject: [PATCH] Fixing issues with previous commit --- lib/Tmdb/Factory/PeopleFactory.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Tmdb/Factory/PeopleFactory.php b/lib/Tmdb/Factory/PeopleFactory.php index f6b2eb56..98c77db1 100644 --- a/lib/Tmdb/Factory/PeopleFactory.php +++ b/lib/Tmdb/Factory/PeopleFactory.php @@ -14,8 +14,6 @@ use Tmdb\Common\ObjectHydrator; use Tmdb\Factory\Common\ChangeFactory; -use Tmdb\Model\Collection\People\Cast; -use Tmdb\Model\Collection\People\Crew; use Tmdb\Model\Collection\People; use Tmdb\Model\Common\ExternalIds; use Tmdb\Model\Person\CastMember; @@ -49,7 +47,7 @@ public function __construct() * * @return Person|CrewMember|CastMember */ - public function create(array $data = array(), Person\AbstractMember $person = null) + public function create(array $data = array(), $person = null) { if (!is_object($person)) { if (array_key_exists('character', $data)) { @@ -99,7 +97,7 @@ public function create(array $data = array(), Person\AbstractMember $person = nu * @param array $data * @param Person $person */ - protected function applyCredits(array $data = array(), Person $person) + protected function applyCredits(array $data, Person $person) { $hydrator = new ObjectHydrator(); $types = array('movie_credits', 'tv_credits', 'combined_credits'); @@ -145,7 +143,7 @@ protected function getPosterImageForCredit($posterPath) /** * {@inheritdoc} */ - public function createCollection(array $data = array(), Person\AbstractMember $person = null, $collection = null) + public function createCollection(array $data = array(), $person = null, $collection = null) { if (!$collection) { $collection = new People(); @@ -155,7 +153,11 @@ public function createCollection(array $data = array(), Person\AbstractMember $p $data = $data['results']; } - $class = get_class($person); + if (is_object($person)) { + $class = get_class($person); + } else { + $class = '\Tmdb\Model\Person'; + } foreach ($data as $item) { $collection->add(null, $this->create($item, new $class()));