libphonenumber\PhoneNumberUtil::canBeInternationallyDialled PHP Method

canBeInternationallyDialled() public method

TODO: Make this method public when we have enough metadata to make it worthwhile.
public canBeInternationallyDialled ( PhoneNumber $number ) : boolean
$number PhoneNumber 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());
    }

Usage Example

コード例 #1
0
 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));
 }
All Usage Examples Of libphonenumber\PhoneNumberUtil::canBeInternationallyDialled
PhoneNumberUtil