diff --git a/lib/Tmdb/Factory/PeopleFactory.php b/lib/Tmdb/Factory/PeopleFactory.php index 91a04f44..f6b2eb56 100644 --- a/lib/Tmdb/Factory/PeopleFactory.php +++ b/lib/Tmdb/Factory/PeopleFactory.php @@ -14,16 +14,14 @@ 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; use Tmdb\Model\Person\CrewMember; use Tmdb\Model\Person; -/** - * Class PeopleFactory - * @package Tmdb\Factory - */ class PeopleFactory extends AbstractFactory { /** @@ -51,7 +49,7 @@ public function __construct() * * @return Person|CrewMember|CastMember */ - public function create(array $data = array(), $person = null) + public function create(array $data = array(), Person\AbstractMember $person = null) { if (!is_object($person)) { if (array_key_exists('character', $data)) { @@ -101,7 +99,7 @@ public function create(array $data = array(), $person = null) * @param array $data * @param Person $person */ - protected function applyCredits(array $data, Person $person) + protected function applyCredits(array $data = array(), Person $person) { $hydrator = new ObjectHydrator(); $types = array('movie_credits', 'tv_credits', 'combined_credits'); @@ -117,7 +115,7 @@ protected function applyCredits(array $data, Person $person) ); foreach ($cast as $member) { - $member->setPosterImage($member->getPosterPath()); + $member->setPosterImage($this->getPosterImageForCredit($member->getPosterPath())); } $person->$method()->setCast($cast); @@ -130,7 +128,7 @@ protected function applyCredits(array $data, Person $person) ); foreach ($crew as $member) { - $member->setPosterImage($member->getPosterPath()); + $member->setPosterImage($this->getPosterImageForCredit($member->getPosterPath())); } $person->$method()->setCrew($crew); @@ -147,7 +145,7 @@ protected function getPosterImageForCredit($posterPath) /** * {@inheritdoc} */ - public function createCollection(array $data = array(), $person = null, $collection = null) + public function createCollection(array $data = array(), Person\AbstractMember $person = null, $collection = null) { if (!$collection) { $collection = new People(); @@ -157,11 +155,7 @@ public function createCollection(array $data = array(), $person = null, $collect $data = $data['results']; } - if (is_object($person)) { - $class = get_class($person); - } else { - $class = '\Tmdb\Model\Person'; - } + $class = get_class($person); foreach ($data as $item) { $collection->add(null, $this->create($item, new $class()));