本文整理匯總了PHP中libphonenumber\PhoneNumberUtil::isNumberGeographical方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhoneNumberUtil::isNumberGeographical方法的具體用法?PHP PhoneNumberUtil::isNumberGeographical怎麽用?PHP PhoneNumberUtil::isNumberGeographical使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類libphonenumber\PhoneNumberUtil
的用法示例。
在下文中一共展示了PhoneNumberUtil::isNumberGeographical方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getDescriptionForNumber
/**
* 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);
}
示例2: testIsNumberGeographical
public function testIsNumberGeographical()
{
$this->assertFalse($this->phoneUtil->isNumberGeographical(self::$bsMobile));
// Bahamas, mobile phone number.
$this->assertTrue($this->phoneUtil->isNumberGeographical(self::$auNumber));
// Australian fixed line number.
$this->assertFalse($this->phoneUtil->isNumberGeographical(self::$internationalTollFree));
// International toll
// free number
}