• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/phonenumber/parser.php
  • Класс: BitrixMainPhoneNumberParser
  • Вызов: Parser::findCountry
protected function findCountry($countryCode, $localNumber)
{
	if(!$countryCode || !$localNumber)
		return false;

	$possibleCountries = MetadataProvider::getInstance()->getCountriesByCode($countryCode);
	if(count($possibleCountries) === 1)
	{
		return $possibleCountries[0];
	}

	foreach($possibleCountries as $possibleCountry)
	{
		$countryMetadata = $this->getCountryMetadata($possibleCountry);

		// Check leading digits first
		if(isset($countryMetadata['leadingDigits']))
		{
			$leadingDigitsRegex = '/^('.$countryMetadata['leadingDigits'].')/';
			if(preg_match($leadingDigitsRegex, $localNumber))
			{
				return $possibleCountry;
			}
		}
		// Else perform full validation with all of those bulky fixed-line/mobile/etc regular expressions.
		else if($this->getNumberType($localNumber, $possibleCountry))
		{
			return $possibleCountry;
		}
	}

	return false;
}