public function fromArray(array $input)
{
if (isset($input['generalDesc'])) {
$desc = new PhoneNumberDesc();
$this->setGeneralDesc($desc->fromArray($input['generalDesc']));
}
if (isset($input['fixedLine'])) {
$desc = new PhoneNumberDesc();
$this->setFixedLine($desc->fromArray($input['fixedLine']));
}
if (isset($input['mobile'])) {
$desc = new PhoneNumberDesc();
$this->setMobile($desc->fromArray($input['mobile']));
}
if (isset($input['tollFree'])) {
$desc = new PhoneNumberDesc();
$this->setTollFree($desc->fromArray($input['tollFree']));
}
if (isset($input['premiumRate'])) {
$desc = new PhoneNumberDesc();
$this->setPremiumRate($desc->fromArray($input['premiumRate']));
}
if (isset($input['sharedCost'])) {
$desc = new PhoneNumberDesc();
$this->setSharedCost($desc->fromArray($input['sharedCost']));
}
if (isset($input['personalNumber'])) {
$desc = new PhoneNumberDesc();
$this->setPersonalNumber($desc->fromArray($input['personalNumber']));
}
if (isset($input['voip'])) {
$desc = new PhoneNumberDesc();
$this->setVoip($desc->fromArray($input['voip']));
}
if (isset($input['pager'])) {
$desc = new PhoneNumberDesc();
$this->setPager($desc->fromArray($input['pager']));
}
if (isset($input['uan'])) {
$desc = new PhoneNumberDesc();
$this->setUan($desc->fromArray($input['uan']));
}
if (isset($input['emergency'])) {
$desc = new PhoneNumberDesc();
$this->setEmergency($desc->fromArray($input['emergency']));
}
if (isset($input['voicemail'])) {
$desc = new PhoneNumberDesc();
$this->setVoicemail($desc->fromArray($input['voicemail']));
}
if (isset($input['shortCode'])) {
$desc = new PhoneNumberDesc();
$this->setShortCode($desc->fromArray($input['shortCode']));
}
if (isset($input['standardRate'])) {
$desc = new PhoneNumberDesc();
$this->setStandardRate($desc->fromArray($input['standardRate']));
}
if (isset($input['carrierSpecific'])) {
$desc = new PhoneNumberDesc();
$this->setCarrierSpecific($desc->fromArray($input['carrierSpecific']));
}
if (isset($input['noInternationalDialling'])) {
$desc = new PhoneNumberDesc();
$this->setNoInternationalDialling($desc->fromArray($input['noInternationalDialling']));
}
$this->setId($input['id']);
$this->setCountryCode($input['countryCode']);
$this->setInternationalPrefix($input['internationalPrefix']);
if (isset($input['preferredInternationalPrefix'])) {
$this->setPreferredInternationalPrefix($input['preferredInternationalPrefix']);
}
if (isset($input['nationalPrefix'])) {
$this->setNationalPrefix($input['nationalPrefix']);
}
if (isset($input['nationalPrefix'])) {
$this->setNationalPrefix($input['nationalPrefix']);
}
if (isset($input['preferredExtnPrefix'])) {
$this->setPreferredExtnPrefix($input['preferredExtnPrefix']);
}
if (isset($input['nationalPrefixForParsing'])) {
$this->setNationalPrefixForParsing($input['nationalPrefixForParsing']);
}
if (isset($input['nationalPrefixTransformRule'])) {
$this->setNationalPrefixTransformRule($input['nationalPrefixTransformRule']);
}
foreach ($input['numberFormat'] as $numberFormatElt) {
$numberFormat = new NumberFormat();
$numberFormat->fromArray($numberFormatElt);
$this->addNumberFormat($numberFormat);
}
foreach ($input['intlNumberFormat'] as $intlNumberFormatElt) {
$numberFormat = new NumberFormat();
$numberFormat->fromArray($intlNumberFormatElt);
$this->addIntlNumberFormat($numberFormat);
}
$this->setMainCountryForCode($input['mainCountryForCode']);
if (isset($input['leadingDigits'])) {
$this->setLeadingDigits($input['leadingDigits']);
}
if (isset($input['leadingZeroPossible'])) {
$this->setLeadingZeroPossible($input['leadingZeroPossible']);
}
if (isset($input['mobileNumberPortableRegion'])) {
$this->setMobileNumberPortableRegion($input['mobileNumberPortableRegion']);
}
return $this;
}
public function loadMetadataFromFile($filePrefix, $regionCode, $countryCallingCode) { $isNonGeoRegion = self::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode; $fileName = $filePrefix . '_' . ($isNonGeoRegion ? $countryCallingCode : $regionCode) . '.php'; if (!is_readable($fileName)) { throw new \RuntimeException('missing metadata: ' . $fileName); } else { $data = (include $fileName); $metadata = new PhoneMetadata(); $metadata->fromArray($data); if ($isNonGeoRegion) { $this->countryCodeToNonGeographicalMetadataMap[$countryCallingCode] = $metadata; } else { $this->regionToMetadataMap[$regionCode] = $metadata; } } }