コード例 #1
0
 /**
  *
  * @param string $regionCode
  * @param DOMElement $element
  * @param string $nationalPrefix
  * @param string $nationalPrefixFormattingRule
  * @return PhoneMetadata 
  */
 private static function loadTerritoryTagMetadata($regionCode, \DOMElement $element, $nationalPrefix, $nationalPrefixFormattingRule)
 {
     $metadata = new PhoneMetadata();
     $metadata->setId($regionCode);
     $metadata->setCountryCode((int) $element->getAttribute(self::COUNTRY_CODE));
     if ($element->hasAttribute(self::LEADING_DIGITS)) {
         $metadata->setLeadingDigits($element->getAttribute(self::LEADING_DIGITS));
     }
     $metadata->setInternationalPrefix($element->getAttribute(self::INTERNATIONAL_PREFIX));
     if ($element->hasAttribute(self::PREFERRED_INTERNATIONAL_PREFIX)) {
         $preferredInternationalPrefix = $element->getAttribute(self::PREFERRED_INTERNATIONAL_PREFIX);
         $metadata->setPreferredInternationalPrefix($preferredInternationalPrefix);
     }
     if ($element->hasAttribute(self::NATIONAL_PREFIX_FOR_PARSING)) {
         $metadata->setNationalPrefixForParsing($element->getAttribute(self::NATIONAL_PREFIX_FOR_PARSING));
         if ($element->hasAttribute(self::NATIONAL_PREFIX_TRANSFORM_RULE)) {
             $metadata->setNationalPrefixTransformRule($element->getAttribute(self::NATIONAL_PREFIX_TRANSFORM_RULE));
         }
     }
     if ($nationalPrefix != '') {
         $metadata->setNationalPrefix($nationalPrefix);
         if (!$metadata->hasNationalPrefixForParsing()) {
             $metadata->setNationalPrefixForParsing($nationalPrefix);
         }
     }
     if ($element->hasAttribute(self::PREFERRED_EXTN_PREFIX)) {
         $metadata->setPreferredExtnPrefix($element->getAttribute(self::PREFERRED_EXTN_PREFIX));
     }
     if ($element->hasAttribute(self::MAIN_COUNTRY_FOR_CODE)) {
         $metadata->setMainCountryForCode(true);
     }
     if ($element->hasAttribute(self::LEADING_ZERO_POSSIBLE)) {
         $metadata->setLeadingZeroPossible(true);
     }
     return $metadata;
 }