libphonenumber\ShortNumberUtil::connectsToEmergencyNumber PHP Méthode

connectsToEmergencyNumber() public méthode

This method takes into account cases where the number might contain formatting, or might have additional digits appended (when it is okay to do that in the region specified).
public connectsToEmergencyNumber ( $number, $regionCode ) : boolean
$number String the phone number to test
$regionCode String the region where the phone number is being dialed
Résultat boolean if the number might be used to connect to an emergency service in the given region.
    public function connectsToEmergencyNumber($number, $regionCode)
    {
        return ShortNumberInfo::getInstance()->connectsToEmergencyNumber($number, $regionCode);
    }

Usage Example

 public function testConnectsToEmergencyNumber_ZW()
 {
     // Zimbabwe doesn't have any metadata in the test metadata.
     $this->assertFalse($this->shortUtil->connectsToEmergencyNumber("911", RegionCode::ZW));
     $this->assertFalse($this->shortUtil->connectsToEmergencyNumber("01312345", RegionCode::ZW));
     $this->assertFalse($this->shortUtil->connectsToEmergencyNumber("0711234567", RegionCode::ZW));
 }