private function getNumberTypeHelper($nationalNumber, PhoneMetadata $metadata)
 {
     $generalNumberDesc = $metadata->getGeneralDesc();
     if (!$generalNumberDesc->hasNationalNumberPattern() || !$this->isNumberMatchingDesc($nationalNumber, $generalNumberDesc)) {
         return PhoneNumberType::UNKNOWN;
     }
     if ($this->isNumberMatchingDesc($nationalNumber, $metadata->getPremiumRate())) {
         return PhoneNumberType::PREMIUM_RATE;
     }
     if ($this->isNumberMatchingDesc($nationalNumber, $metadata->getTollFree())) {
         return PhoneNumberType::TOLL_FREE;
     }
     /*
     * @todo Implement other phone desc
      if ($this->isNumberMatchingDesc($nationalNumber, $metadata->getSharedCost())) {
      return PhoneNumberType::SHARED_COST;
      }
      if ($this->isNumberMatchingDesc($nationalNumber, $metadata->getVoip())) {
      return PhoneNumberType::VOIP;
      }
      if ($this->isNumberMatchingDesc($nationalNumber, $metadata->getPersonalNumber())) {
      return PhoneNumberType::PERSONAL_NUMBER;
      }
      if ($this->isNumberMatchingDesc($nationalNumber, $metadata->getPager())) {
      return PhoneNumberType::PAGER;
      }
      if ($this->isNumberMatchingDesc($nationalNumber, $metadata->getUan())) {
      return PhoneNumberType::UAN;
      }
      if ($this->isNumberMatchingDesc($nationalNumber, $metadata->getVoicemail())) {
      return PhoneNumberType::VOICEMAIL;
      }
     */
     $isFixedLine = $this->isNumberMatchingDesc($nationalNumber, $metadata->getFixedLine());
     if ($isFixedLine) {
         if ($metadata->isSameMobileAndFixedLinePattern()) {
             return PhoneNumberType::FIXED_LINE_OR_MOBILE;
         } else {
             if ($this->isNumberMatchingDesc($nationalNumber, $metadata->getMobile())) {
                 return PhoneNumberType::FIXED_LINE_OR_MOBILE;
             }
         }
         return PhoneNumberType::FIXED_LINE;
     }
     // Otherwise, test to see if the number is mobile. Only do this if certain that the patterns for
     // mobile and fixed line aren't the same.
     if (!$metadata->isSameMobileAndFixedLinePattern() && $this->isNumberMatchingDesc($nationalNumber, $metadata->getMobile())) {
         return PhoneNumberType::MOBILE;
     }
     return PhoneNumberType::UNKNOWN;
 }
 /**
  * @param PhoneMetadata $metadata
  * @param int $type PhoneNumberType
  * @return PhoneNumberDesc
  */
 private function getNumberDescByType(PhoneMetadata $metadata, $type)
 {
     switch ($type) {
         case PhoneNumberType::PREMIUM_RATE:
             return $metadata->getPremiumRate();
         case PhoneNumberType::TOLL_FREE:
             return $metadata->getTollFree();
         case PhoneNumberType::MOBILE:
             return $metadata->getMobile();
         case PhoneNumberType::FIXED_LINE:
         case PhoneNumberType::FIXED_LINE_OR_MOBILE:
             return $metadata->getFixedLine();
         case PhoneNumberType::SHARED_COST:
             return $metadata->getSharedCost();
         case PhoneNumberType::VOIP:
             return $metadata->getVoip();
         case PhoneNumberType::PERSONAL_NUMBER:
             return $metadata->getPersonalNumber();
         case PhoneNumberType::PAGER:
             return $metadata->getPager();
         case PhoneNumberType::UAN:
             return $metadata->getUan();
         case PhoneNumberType::VOICEMAIL:
             return $metadata->getVoicemail();
         default:
             return $metadata->getGeneralDesc();
     }
 }
 private static function loadGeneralDesc(PhoneMetadata $metadata, \DOMElement $element)
 {
     $generalDesc = new PhoneNumberDesc();
     $generalDesc = self::processPhoneNumberDescElement($generalDesc, $element, self::GENERAL_DESC);
     $metadata->setGeneralDesc($generalDesc);
     $metadata->setFixedLine(self::processPhoneNumberDescElement($generalDesc, $element, self::FIXED_LINE));
     $metadata->setMobile(self::processPhoneNumberDescElement($generalDesc, $element, self::MOBILE));
     $metadata->setPremiumRate(self::processPhoneNumberDescElement($generalDesc, $element, self::PREMIUM_RATE));
     $metadata->setTollFree(self::processPhoneNumberDescElement($generalDesc, $element, self::TOLL_FREE));
     $metadata->setSharedCost(self::processPhoneNumberDescElement($generalDesc, $element, self::SHARED_COST));
     /*
     * @todo
      $metadata->setVoip(self::processPhoneNumberDescElement($generalDesc, $element, self::VOIP));
      $metadata->setPersonalNumber(self::processPhoneNumberDescElement($generalDesc, $element, self::PERSONAL_NUMBER));
      $metadata->setPager(self::processPhoneNumberDescElement($generalDesc, $element, self::PAGER));
      $metadata->setUan(self::processPhoneNumberDescElement($generalDesc, $element, self::UAN));
      $metadata->setEmergency(self::processPhoneNumberDescElement($generalDesc, $element, self::EMERGENCY));
     * 
     */
     $metadata->setNoInternationalDialling(self::processPhoneNumberDescElement($generalDesc, $element, self::NO_INTERNATIONAL_DIALLING));
     $metadata->setSameMobileAndFixedLinePattern($metadata->getMobile()->getNationalNumberPattern() === $metadata->getFixedLine()->getNationalNumberPattern());
 }