/**
* As per getDescriptionForValidNumber, but explicitly checks the validity of the number
* passed in.
*
*
* @see getDescriptionForValidNumber
* @param PhoneNumber $number a valid phone number for which we want to get a text description
* @param string $locale the language code for which the description should be written
* @param string $userRegion the region code for a given user. This region will be omitted from the
* description if the phone number comes from this region. It is a two-letter uppercase ISO
* country code as defined by ISO 3166-1.
* @return string a text description for the given language code for the given phone number, or empty
* string if the number passed in is invalid
*/
public function getDescriptionForNumber(PhoneNumber $number, $locale, $userRegion = null)
{
$numberType = $this->phoneUtil->getNumberType($number);
if ($numberType === PhoneNumberType::UNKNOWN) {
return "";
} elseif (!$this->phoneUtil->isNumberGeographical($numberType, $number->getCountryCode())) {
return $this->getCountryNameForNumber($number, $locale);
}
return $this->getDescriptionForValidNumber($number, $locale, $userRegion);
}