isValidShortNumberForRegion() public method

Tests whether a short number matches a valid pattern in a region. Note that this doesn't verify the number is actually in use, which is impossible to tell by just looking at the number itself.
public isValidShortNumberForRegion ( PhoneNumber | string $number, string $regionDialingFrom ) : boolean
$number PhoneNumber | string The Short number for which we want to test the validity
$regionDialingFrom string the region from which the number is dialed
return boolean whether the short number matches a valid pattern
 public function testCountryCallingCodeIsNotIgnored()
 {
     // +46 is the country calling code for Sweden (SE), and 40404 is a valid short number in the US.
     $this->assertFalse($this->shortInfo->isPossibleShortNumberForRegion($this->parse('+4640404', RegionCode::SE), RegionCode::US));
     $this->assertFalse($this->shortInfo->isValidShortNumberForRegion($this->parse('+4640404', RegionCode::SE), RegionCode::US));
     $this->assertEquals(ShortNumberCost::UNKNOWN_COST, $this->shortInfo->getExpectedCostForRegion($this->parse('+4640404', RegionCode::SE), RegionCode::US));
 }
    /**
     * @dataProvider shortNumberRegionList
     */
    public function testShortNumbersValidAndCorrectCost($regionCode)
    {
        $exampleShortNumber = $this->shortNumberInfo->getExampleShortNumber($regionCode);
        if (!$this->shortNumberInfo->isValidShortNumberForRegion(
            $this->phoneNumberUtil->parse($exampleShortNumber, $regionCode),
            $regionCode
        )
        ) {
            $this->fail(
                "Failed validation for string region_code: {$regionCode}, national_number: {$exampleShortNumber}"
            );
        }
        $phoneNumber = $this->phoneNumberUtil->parse($exampleShortNumber, $regionCode);
        if (!$this->shortNumberInfo->isValidShortNumber($phoneNumber)) {
            $this->fail("Failed validation for " . (string)$phoneNumber);
        }

        $costArray = array(
            ShortNumberCost::PREMIUM_RATE,
            ShortNumberCost::STANDARD_RATE,
            ShortNumberCost::TOLL_FREE,
            ShortNumberCost::UNKNOWN_COST
        );

        foreach ($costArray as $cost) {
            $exampleShortNumber = $this->shortNumberInfo->getExampleShortNumberForCost($regionCode, $cost);
            if ($exampleShortNumber != '') {
                $this->assertEquals(
                    $cost,
                    $this->shortNumberInfo->getExpectedCostForRegion($this->phoneNumberUtil->parse($exampleShortNumber, $regionCode), $regionCode),
                    "Wrong cost for " . (string)$phoneNumber
                );
            }
        }
    }
 public function testEmergencyNumberForSharedCountryCallingCode()
 {
     // Test the emergency number 112, which is valid in both Australia and the Christmas Islands.
     $this->assertTrue($this->shortInfo->isEmergencyNumber("112", RegionCode::AU));
     $this->assertTrue($this->shortInfo->isValidShortNumberForRegion("112", RegionCode::AU));
     $this->assertEquals(ShortNumberCost::TOLL_FREE, $this->shortInfo->getExpectedCostForRegion("112", RegionCode::AU));
     $this->assertTrue($this->shortInfo->isEmergencyNumber("112", RegionCode::CX));
     $this->assertTrue($this->shortInfo->isValidShortNumberForRegion("112", RegionCode::CX));
     $this->assertEquals(ShortNumberCost::TOLL_FREE, $this->shortInfo->getExpectedCostForRegion("112", RegionCode::CX));
     $sharedEmergencyNumber = new PhoneNumber();
     $sharedEmergencyNumber->setCountryCode(61)->setNationalNumber(112);
     $this->assertTrue($this->shortInfo->isValidShortNumber($sharedEmergencyNumber));
     $this->assertEquals(ShortNumberCost::TOLL_FREE, $this->shortInfo->getExpectedCost($sharedEmergencyNumber));
 }