/**
  * Factory method for creating a QuickContact object from an array.
  *
  * @param array $arr array to construct a QuickContact object from
  * @return QuickContact QuickContact response object
  */
 public static function fromArray($arr)
 {
     $qcontact = new QuickContact();
     $mappings = array('contactId' => &$qcontact->_contactId, 'formattedName' => &$qcontact->_formattedName, 'firstName' => &$qcontact->_firstName, 'middleName' => &$qcontact->_middleName, 'lastName' => &$qcontact->_lastName, 'prefix' => &$qcontact->_prefix, 'suffix' => &$qcontact->_suffix, 'nickName' => &$qcontact->_nickname, 'organization' => &$qcontact->_organization);
     foreach ($mappings as $k => $v) {
         if (isset($arr[$k])) {
             $mappings[$k] = $arr[$k];
         }
     }
     if (isset($arr['phone'])) {
         $qcontact->_phone = Phone::fromArray($arr['phone']);
     }
     if (isset($arr['email'])) {
         $qcontact->_email = Email::fromArray($arr['email']);
     }
     if (isset($arr['im'])) {
         $qcontact->_im = Im::fromArray($arr['im']);
     }
     if (isset($arr['address'])) {
         $qcontact->_addr = Address::fromArray($arr['address']);
     }
     return $qcontact;
 }
 /**
  * Factory method for creating a ContactCommon object from an array.
  *
  * @param array $arr array to construct a Contact object from
  * @return Contact Contact response object
  */
 public static function fromArray($contactArr)
 {
     $contact = new ContactCommon();
     $mappings = array('firstName' => &$contact->firstName, 'middleName' => &$contact->middleName, 'lastName' => &$contact->lastName, 'prefix' => &$contact->prefix, 'suffix' => &$contact->suffix, 'nickName' => &$contact->nickname, 'organization' => &$contact->organization, 'jobTitle' => &$contact->jobTitle, 'anniversary' => &$contact->anniversary, 'gender' => &$contact->gender, 'spouse' => &$contact->spouse, 'hobby' => &$contact->hobby, 'assistant' => &$contact->assistant);
     foreach ($mappings as $k => $v) {
         if (isset($contactArr[$k])) {
             $mappings[$k] = $contactArr[$k];
         }
     }
     // TODO: look into cleaning up/refactoring code
     if (isset($contactArr['phones'])) {
         $phonesObj = $contactArr['phones'];
         foreach ($phonesObj['phone'] as $phoneArr) {
             $contact->phones[] = Phone::fromArray($phoneArr);
         }
     }
     if (isset($contactArr['addresses'])) {
         $addressesObj = $contactArr['addresses'];
         foreach ($addressesObj['address'] as $addressArr) {
             $contact->addresses[] = Address::fromArray($addressArr);
         }
     }
     if (isset($contactArr['emails'])) {
         $emailsObj = $contactArr['emails'];
         foreach ($emailsObj['email'] as $emailArr) {
             $contact->emails[] = Email::fromArray($emailArr);
         }
     }
     if (isset($contactArr['ims'])) {
         $imsObj = $contactArr['ims'];
         if (isset($imsObj['im'])) {
             foreach ($imsObj['im'] as $imArr) {
                 $contact->ims[] = Im::fromArray($imArr);
             }
         } else {
             foreach ($imsObj['IM'] as $imArr) {
                 $contact->ims[] = Im::fromArray($imArr);
             }
         }
     }
     if (isset($contactArr['weburls'])) {
         $weburlsObj = $contactArr['weburls'];
         foreach ($weburlsObj['webUrl'] as $weburlArr) {
             $contact->weburls[] = WebUrl::fromArray($weburlArr);
         }
     }
     return $contact;
 }