isNumberMatch() публичный Метод

Returns EXACT_MATCH if the country_code, NSN, presence of a leading zero for Italian numbers and any extension present are the same. Returns NSN_MATCH if either or both has no region specified, and the NSNs and extensions are the same. Returns SHORT_NSN_MATCH if either or both has no region specified, or the region specified is the same, and one NSN could be a shorter version of the other number. This includes the case where one has an extension specified, and the other does not. Returns NO_MATCH otherwise. For example, the numbers +1 345 657 1234 and 657 1234 are a SHORT_NSN_MATCH. The numbers +1 345 657 1234 and 345 657 are a NO_MATCH.

public isNumberMatch ( $firstNumberIn, $secondNumberIn ) : integer
$firstNumberIn PhoneNumber|string First number to compare. If it is a string it can contain formatting, and can have country calling code specified with + at the start.
$secondNumberIn PhoneNumber|string Second number to compare. If it is a string it can contain formatting, and can have country calling code specified with + at the start.
Результат integer {MatchType} NOT_A_NUMBER, NO_MATCH,
 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));
 }