• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/phonenumber/parser.php
  • Класс: BitrixMainPhoneNumberParser
  • Вызов: Parser::getNumberType
protected function getNumberType($localNumber, $country)
{
	// Check that the number is valid for this country
	$countryMetadata = $this->getCountryMetadata($country);
	if(!$countryMetadata)
		return false;

	if(isset($countryMetadata['generalDesc']['nationalNumberPattern']))
	{
		$nationalNumberRegex = '/^(?:' . $countryMetadata['generalDesc']['nationalNumberPattern'] . ')$/';
		if(!preg_match($nationalNumberRegex, $localNumber))
			return false;
	}

	$possibleTypes = array('noInternationalDialling', 'areaCodeOptional', 'fixedLine', 'mobile', 'pager', 'tollFree', 'premiumRate', 'sharedCost', 'personalNumber', 'voip', 'uan', 'voicemail');
	foreach ($possibleTypes as $possibleType)
	{
		if(isset($countryMetadata[$possibleType]['nationalNumberPattern']))
		{
			// skip checking possible lengths for now

			$numberTypeRegex = '/^' . $countryMetadata[$possibleType]['nationalNumberPattern'] . '$/';
			if(preg_match($numberTypeRegex, $localNumber))
			{
				return $possibleType;
			}
		}
	}
	return false;
 	}