本文整理汇总了PHP中Phone::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Phone::fromArray方法的具体用法?PHP Phone::fromArray怎么用?PHP Phone::fromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phone
的用法示例。
在下文中一共展示了Phone::fromArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromArray
/**
* 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;
}
示例2: fromArray
/**
* 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;
}