src/ShortNumberInfo.php
public function isValidShortNumberForRegion(PhoneNumber $number, $regionDialingFrom)
    {
        if (!$this->regionDialingFromMatchesNumber($number, $regionDialingFrom)) {
            return false;
        }
        $phoneMetadata = $this->getMetadataForRegion($regionDialingFrom);

        if ($phoneMetadata === null) {
            return false;
        }

        $shortNumber = $this->getNationalSignificantNumber($number);

        $generalDesc = $phoneMetadata->getGeneralDesc();

        if (!$this->matchesPossibleNumberAndNationalNumber($shortNumber, $generalDesc)) {
            return false;
        }

        $shortNumberDesc = $phoneMetadata->getShortCode();

        return $this->matchesPossibleNumberAndNationalNumber($shortNumber, $shortNumberDesc);
    }
public function isValidShortNumberForRegion(PhoneNumber $number, $regionDialingFrom)
    {
        if (!$this->regionDialingFromMatchesNumber($number, $regionDialingFrom)) {
            return false;
        }
        $phoneMetadata = $this->getMetadataForRegion($regionDialingFrom);

        if ($phoneMetadata === null) {
            return false;
        }

        $shortNumber = $this->getNationalSignificantNumber($number);

        $generalDesc = $phoneMetadata->getGeneralDesc();

        if (!$this->matchesPossibleNumberAndNationalNumber($shortNumber, $generalDesc)) {
            return false;
        }

        $shortNumberDesc = $phoneMetadata->getShortCode();

        return $this->matchesPossibleNumberAndNationalNumber($shortNumber, $shortNumberDesc);
    }
public function isValidShortNumberForRegion ( PhoneNumber $ number , $ regionDialingFrom ) { if ( ! $ this -> regionDialingFromMatchesNumber ( $ number , $ regionDialingFrom ) ) { return false ; } $ phoneMetadata = $ this -> getMetadataForRegion ( $ regionDialingFrom ) ; if ( $ phoneMetadata === null ) { return false ; } $ shortNumber = $ this -> getNationalSignificantNumber ( $ number ) ; $ generalDesc = $ phoneMetadata -> getGeneralDesc ( ) ; if ( ! $ this -> matchesPossibleNumberAndNationalNumber ( $ shortNumber , $ generalDesc ) ) { return false ; } $ shortNumberDesc = $ phoneMetadata -> getShortCode ( ) ; return $ this -> matchesPossibleNumberAndNationalNumber ( $ shortNumber , $ shortNumberDesc ) ; }
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.

@param PhoneNumber $number The Short number for which we want to test the validity
@param string $regionDialingFrom the region from which the number is dialed
@return boolean whether the short number matches a valid pattern
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 .