libphonenumber\ShortNumberInfo::isEmergencyNumber PHP Method

isEmergencyNumber() public method

This method takes into account cases where the number might contain formatting, but doesn't allow additional digits to be appended. Note that {@code isEmergencyNumber(number, region)} implies {@code connectsToEmergencyNumber(number, region)}.

public isEmergencyNumber ( string $number, string $regionCode ) : boolean
$number string the phone number to test
$regionCode string the region where the phone number is being dialled
return boolean whether the number exactly matches an emergency services number in the given region
    public function isEmergencyNumber($number, $regionCode)
    {
        return $this->matchesEmergencyNumberHelper($number, $regionCode, false);
    }

Usage Example

 public function testOverlappingNANPANumber()
 {
     // 211 is an emergency number in Barbados, while it is a toll-free information line in Canada
     // and the USA.
     $this->assertTrue($this->shortInfo->isEmergencyNumber("211", RegionCode::BB));
     $this->assertEquals(ShortNumberCost::TOLL_FREE, $this->shortInfo->getExpectedCostForRegion($this->parse("211", RegionCode::BB), RegionCode::BB));
     $this->assertFalse($this->shortInfo->isEmergencyNumber("211", RegionCode::US));
     $this->assertEquals(ShortNumberCost::UNKNOWN_COST, $this->shortInfo->getExpectedCostForRegion($this->parse("211", RegionCode::US), RegionCode::US));
     $this->assertFalse($this->shortInfo->isEmergencyNumber("211", RegionCode::CA));
     $this->assertEquals(ShortNumberCost::UNKNOWN_COST, $this->shortInfo->getExpectedCostForRegion($this->parse("211", RegionCode::CA), RegionCode::CA));
 }
All Usage Examples Of libphonenumber\ShortNumberInfo::isEmergencyNumber