/**
  * @expectedException \Exception
  * @expectedExceptionMessage Member must have at least an email.
  */
 public function testShouldThrowExceptionIfEmailIsEmpty()
 {
     MemberFactory::create('');
 }
 /**
  * Handle response of user profile search to return an abstract Member object
  *
  * @param array $response
  *
  * @return Member
  */
 private function memberHandleResponse(array $response)
 {
     $member = MemberFactory::create($response['EMAIL']);
     $member->setFirstName($response['FIRSTNAME'])->setLastName($response['LASTNAME'])->setEmailOrigin($response['EMAIL_ORIGINE'])->setCellphone($response['EMVCELLPHONE']);
     if (null !== $response['DATEOFBIRTH']) {
         $member->setBirthdayDate(new \DateTime($response['DATEOFBIRTH']));
     }
     if (null !== $response['DATE_SUBSCRIBE']) {
         $member->setDateSubscribe(new \DateTime($response['DATE_SUBSCRIBE']));
     }
     // Handle custom fields
     $responseFieldAvailable = array_keys($response);
     foreach (EnumMemberCustomField::getSupportedValues() as $fieldName) {
         if (in_array($fieldName, $responseFieldAvailable)) {
             $setter = 'set' . StringToPascalCase::convert(strtolower($fieldName));
             if (!method_exists($member, $setter)) {
                 continue;
             }
             $value = $response[$fieldName];
             if (null === $value) {
                 continue;
             }
             $member->{$setter}($value);
         }
     }
     return $member;
 }
 /**
  * Handle response of user profile search to return an abstract Member object
  *
  * @param array $response
  *
  * @return Member
  */
 private function memberHandleResponse(array $response)
 {
     $member = MemberFactory::create($response['data']['email']);
     $member->setFirstName($response['data']['attributes']['FIRSTNAME'])->setLastName($response['data']['attributes']['LASTNAME']);
     if (null !== $response['data']['entered']) {
         $member->setDateSubscribe(new \DateTime($response['data']['entered']));
     }
     // Handle custom fields
     $responseFieldAvailable = array_keys($response);
     foreach (EnumMemberCustomField::getSupportedValues() as $fieldName) {
         if (in_array($fieldName, $responseFieldAvailable)) {
             $setter = 'set' . StringToPascalCase::convert(strtolower($fieldName));
             if (!method_exists($member, $setter)) {
                 continue;
             }
             $value = $response[$fieldName];
             if (null === $value) {
                 continue;
             }
             $member->{$setter}($value);
         }
     }
     return $member;
 }
 /**
  * Create new member
  * 
  * @param $email
  *
  * @return Member\Member
  */
 public function createNewMember($email)
 {
     return MemberFactory::create($email);
 }