public function isPossibleShortNumberForRegion($shortNumber, $regionDialingFrom)
{
if ($shortNumber instanceof PhoneNumber) {
if (!$this->regionDialingFromMatchesNumber($shortNumber, $regionDialingFrom)) {
return false;
}
}
$phoneMetadata = $this->getMetadataForRegion($regionDialingFrom);
if ($phoneMetadata === null) {
return false;
}
if ($shortNumber instanceof PhoneNumber) {
$numberLength = strlen($this->getNationalSignificantNumber($shortNumber));
return in_array($numberLength, $phoneMetadata->getGeneralDesc()->getPossibleLength());
} else {
/**
* @deprecated Anyone who was using it and passing in a string with whitespace (or other
* formatting characters) would have been getting the wrong result. You should parse
* the string to PhoneNumber and use the method
* {@code #isPossibleShortNumberForRegion(PhoneNumber, String)}. This method will be
* removed in the next release.
*/
return in_array(strlen($shortNumber), $phoneMetadata->getGeneralDesc()->getPossibleLength());
}
}