本文整理匯總了PHP中libphonenumber\PhoneNumberUtil::isNumberMatch方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhoneNumberUtil::isNumberMatch方法的具體用法?PHP PhoneNumberUtil::isNumberMatch怎麽用?PHP PhoneNumberUtil::isNumberMatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類libphonenumber\PhoneNumberUtil
的用法示例。
在下文中一共展示了PhoneNumberUtil::isNumberMatch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testIsNumberMatchShortNsnMatches
public function testIsNumberMatchShortNsnMatches()
{
// Short NSN matches with the country not specified for either one or both numbers.
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("+64 3 331-6005", "331 6005"));
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("+64 3 331-6005", "tel:331-6005;phone-context=abc.nz"));
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("+64 3 331-6005", "tel:331-6005;isub=1234;phone-context=abc.nz"));
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("+64 3 331-6005", "tel:331-6005;isub=1234;phone-context=abc.nz;a=%A1"));
// We did not know that the "0" was a national prefix since neither number has a country code,
// so this is considered a SHORT_NSN_MATCH.
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("3 331-6005", "03 331 6005"));
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("3 331-6005", "331 6005"));
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("3 331-6005", "tel:331-6005;phone-context=abc.nz"));
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("3 331-6005", "+64 331 6005"));
// Short NSN match with the country specified.
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("03 331-6005", "331 6005"));
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("1 234 345 6789", "345 6789"));
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("+1 (234) 345 6789", "345 6789"));
// NSN matches, country calling code omitted for one number, extension missing for one.
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch("+64 3 331-6005", "3 331 6005#1234"));
// One has Italian leading zero, one does not.
$italianNumberOne = new PhoneNumber();
$italianNumberOne->setCountryCode(39)->setNationalNumber(1234)->setItalianLeadingZero(true);
$italianNumberTwo = new PhoneNumber();
$italianNumberTwo->setCountryCode(39)->setNationalNumber(1234);
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch($italianNumberOne, $italianNumberTwo));
// One has an extension, the other has an extension of "".
$italianNumberOne->setExtension("1234")->clearItalianLeadingZero();
$italianNumberTwo->setExtension("");
$this->assertEquals(MatchType::SHORT_NSN_MATCH, $this->phoneUtil->isNumberMatch($italianNumberOne, $italianNumberTwo));
}