public canBeInternationallyDialled ( |
||
$number | the phone-number for which we want to know whether it is diallable from outside the region | |
return | boolean |
public function canBeInternationallyDialled(PhoneNumber $number)
{
$metadata = $this->getMetadataForRegion($this->getRegionCodeForNumber($number));
if ($metadata === null) {
// Note numbers belonging to non-geographical entities (e.g. +800 numbers) are always
// internationally diallable, and will be caught here.
return true;
}
$nationalSignificantNumber = $this->getNationalSignificantNumber($number);
return !$this->isNumberMatchingDesc($nationalSignificantNumber, $metadata->getNoInternationalDialling());
}
public function testCanBeInternationallyDialled() { // We have no-international-dialling rules for the US in our test metadata that say that // toll-free numbers cannot be dialled internationally. $this->assertFalse($this->phoneUtil->canBeInternationallyDialled(self::$usTollFree)); // Normal US numbers can be internationally dialled. $this->assertTrue($this->phoneUtil->canBeInternationallyDialled(self::$usNumber)); // Invalid number. $this->assertTrue($this->phoneUtil->canBeInternationallyDialled(self::$usLocalNumber)); // We have no data for NZ - should return true. $this->assertTrue($this->phoneUtil->canBeInternationallyDialled(self::$nzNumber)); $this->assertTrue($this->phoneUtil->canBeInternationallyDialled(self::$internationalTollFree)); }