/**
  * {@inheritdoc}
  */
 public function hydrate(array $data)
 {
     // TODO: make a factory
     $person = new Person();
     $person->setId(isset($data['id']) ? $data['id'] : null);
     $person->setBirthDate(isset($data['birthDate']) ? $data['birthDate'] : null);
     $person->setDescription(isset($data['description']) ? $data['description'] : null);
     $person->setEmail(isset($data['email']) ? $data['email'] : null);
     $person->setFamilyName(isset($data['familyName']) ? $data['familyName'] : null);
     $person->setGender(isset($data['gender']) ? $data['gender'] : null);
     $person->setGivenName(isset($data['givenName']) ? $data['givenName'] : null);
     $person->setJobTitle(isset($data['jobTitle']) ? $data['jobTitle'] : null);
     $person->setNationality(isset($data['nationality']) ? $data['nationality'] : null);
     $person->setTelephone(isset($data['telephone']) ? $data['telephone'] : null);
     if (isset($data['studies'])) {
         foreach ($data['studies'] as $studyData) {
             $person->addStudy($this->studyHydrator->hydrate($studyData));
         }
     }
     if (isset($data['experiences'])) {
         foreach ($data['experiences'] as $studyData) {
             $person->addExperience($this->experienceHydrator->hydrate($studyData));
         }
     }
     return $person;
 }
Exemple #2
0
 /**
  * Test the addition of a study in a Person.
  */
 public function testAddStudy()
 {
     // GIVEN
     $person = new Person();
     $study = new Study();
     // WHEN
     $person->addStudy($study);
     // THEN
     $this->assertInternalType('array', $person->getStudies());
     $this->assertCount(1, $person->getStudies());
 }