code: private function addAPerson(array $person, ObjectManager $manager)
      {
          $p = new Person();
  
          foreach ($person as $key => $value) {
              switch ($key) {
                  case 'CountryOfBirth':
                  case 'Nationality':
                      $value = $this->getCountry($value);
                      break;
                  case 'Birthdate':
                      $value = new \DateTime($value);
                      break;
                  case 'center':
                  case 'maritalStatus':
                      $value = $this->getReference($value);
                      break;
              }
              
              //try to add the data using the setSomething function,
              // if not possible, fallback to addSomething function
              if (method_exists($p, 'set'.$key)) {
                  call_user_func(array($p, 'set'.$key), $value);
              } elseif (method_exists($p, 'add'.$key)) {
                  // if we have a "addSomething", we may have multiple items to add
                  // so, we set the value in an array if it is not an array, and 
                  // will call the function addSomething multiple times
                  if (!is_array($value)) {
                      $value = array($value);
                  }
                  
                  foreach($value as $v) {
                      if ($v !== NULL) {
                          call_user_func(array($p, 'add'.$key), $v);
                      }
                  }
                  
              } 
          }
  
          $manager->persist($p);
          echo "add person'".$p->__toString()."'\n";
      }
docs: create a new person from array data
  
  @param array $person
  @param ObjectManager $manager
  @throws \Exception