From d24e6d1d8af13691e8d38dcf64570ebfb42c90e6 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Tue, 4 Feb 2014 01:34:20 +0100 Subject: [PATCH] Fixing some bugs --- lib/Tmdb/Factory/PeopleFactory.php | 18 +++++++++--------- lib/Tmdb/Model/Collection.php | 2 +- lib/Tmdb/Model/Person/AbstractMember.php | 6 ++++-- lib/Tmdb/Model/Tv/Season.php | 2 +- test/Tmdb/Tests/Factory/PeopleFactoryTest.php | 11 +++++++++++ 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/lib/Tmdb/Factory/PeopleFactory.php b/lib/Tmdb/Factory/PeopleFactory.php index 322b2e24..a94d7e82 100644 --- a/lib/Tmdb/Factory/PeopleFactory.php +++ b/lib/Tmdb/Factory/PeopleFactory.php @@ -66,17 +66,17 @@ public function create(array $data = array(), Person\AbstractMember $person = nu } } - /** Images */ - if (array_key_exists('images', $data)) { - $person->setImages($this->getImageFactory()->createCollectionFromPeople($data['images'])); - } + if ($person instanceof Person) { + /** Images */ + if (array_key_exists('images', $data)) { + $person->setImages($this->getImageFactory()->createCollectionFromPeople($data['images'])); + } - if (array_key_exists('profile_path', $data)) { - $person->setProfile($this->getImageFactory()->createFromPath($data['profile_path'], 'profile_path')); - } + if (array_key_exists('profile_path', $data)) { + $person->setProfile($this->getImageFactory()->createFromPath($data['profile_path'], 'profile_path')); + } - /** Credits */ - if ($person instanceof Person) { + /** Credits */ $this->applyCredits($data, $person); } diff --git a/lib/Tmdb/Model/Collection.php b/lib/Tmdb/Model/Collection.php index 866663d8..d0ac3277 100644 --- a/lib/Tmdb/Model/Collection.php +++ b/lib/Tmdb/Model/Collection.php @@ -75,7 +75,7 @@ class Collection extends AbstractModel { public function __construct() { $this->parts = new GenericCollection(); - $this->iamges = new Images(); + $this->images = new Images(); } /** diff --git a/lib/Tmdb/Model/Person/AbstractMember.php b/lib/Tmdb/Model/Person/AbstractMember.php index 76e4d82c..47a82b2e 100644 --- a/lib/Tmdb/Model/Person/AbstractMember.php +++ b/lib/Tmdb/Model/Person/AbstractMember.php @@ -20,6 +20,7 @@ abstract class AbstractMember extends AbstractModel { private $id; private $name; private $profilePath; + private $order; /** * @var Image @@ -29,6 +30,7 @@ abstract class AbstractMember extends AbstractModel { public static $_properties = array( 'id', 'name', + 'order', 'profile_path' ); @@ -87,7 +89,7 @@ public function getProfilePath() } /** - * @param mixed $order + * @param integer $order * @return $this */ public function setOrder($order) @@ -97,7 +99,7 @@ public function setOrder($order) } /** - * @return mixed + * @return integer */ public function getOrder() { diff --git a/lib/Tmdb/Model/Tv/Season.php b/lib/Tmdb/Model/Tv/Season.php index e12e4e03..aca7f459 100644 --- a/lib/Tmdb/Model/Tv/Season.php +++ b/lib/Tmdb/Model/Tv/Season.php @@ -235,7 +235,7 @@ public function getSeasonNumber() } /** - * @param GenericCollection $credits + * @param Credits $credits * @return $this */ public function setCredits($credits) diff --git a/test/Tmdb/Tests/Factory/PeopleFactoryTest.php b/test/Tmdb/Tests/Factory/PeopleFactoryTest.php index ec32e3c3..3098ccfb 100644 --- a/test/Tmdb/Tests/Factory/PeopleFactoryTest.php +++ b/test/Tmdb/Tests/Factory/PeopleFactoryTest.php @@ -136,6 +136,17 @@ public function shouldBeFunctional() $this->assertInstanceOf('Tmdb\Model\Collection\Credits\TvCredits', $this->person->getTvCredits()); } + /** + * @test + */ + public function shouldSetDeathDay() + { + $person = new Person(); + $person->setDeathday('2013-12-12'); + + $this->assertInstanceOf('\DateTime', $person->getDeathday()); + } + protected function getFactoryClass() { return 'Tmdb\Factory\PeopleFactory';