Beispiel #1
0
 /**
  * @param array                      $data
  * @param Person\AbstractMember|null $person
  *
  * @return Person|CrewMember|CastMember
  */
 public function create(array $data = array(), $person = null)
 {
     if (!is_object($person)) {
         if (array_key_exists('character', $data)) {
             $person = new CastMember();
         }
         if (array_key_exists('job', $data)) {
             $person = new CrewMember();
         }
         if (null === $person) {
             $person = new Person();
         }
     }
     if (array_key_exists('profile_path', $data)) {
         $person->setProfileImage($this->getImageFactory()->createFromPath($data['profile_path'], 'profile_path'));
     }
     if ($person instanceof Person) {
         /** Images */
         if (array_key_exists('images', $data)) {
             $person->setImages($this->getImageFactory()->createCollectionFromPeople($data['images']));
         }
         /** Credits */
         $this->applyCredits($data, $person);
     }
     if (array_key_exists('changes', $data)) {
         $person->setChanges($this->getChangeFactory()->createCollection($data['changes']));
     }
     /** External ids */
     if (array_key_exists('external_ids', $data)) {
         $person->setExternalIds($this->hydrate(new ExternalIds(), $data['external_ids']));
     }
     return $this->hydrate($person, $data);
 }
Beispiel #2
0
 /**
  * @test
  */
 public function shouldAllowOverridingDefaultCollectionObjects()
 {
     $movie = new Person();
     $class = new GenericCollection();
     $className = get_class($class);
     $movie->setChanges($class);
     $this->assertInstancesOf($movie, array('getChanges' => $className));
 }
Beispiel #3
0
 /**
  * @test
  */
 public function shouldSetDeathDay()
 {
     $person = new Person();
     $person->setDeathday('2013-12-12');
     $this->assertInstanceOf('\\DateTime', $person->getDeathday());
 }