src/ShortNumberInfo.php
protected function getRegionCodeForShortNumberFromRegionList(PhoneNumber $number, $regionCodes)
    {
        if (count($regionCodes) == 0) {
            return null;
        }

        if (count($regionCodes) == 1) {
            return $regionCodes[0];
        }

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

        foreach ($regionCodes as $regionCode) {
            $phoneMetadata = $this->getMetadataForRegion($regionCode);
            if ($phoneMetadata !== null
                && $this->matchesPossibleNumberAndNationalNumber($nationalNumber, $phoneMetadata->getShortCode())
            ) {
                // The number is valid for this region.
                return $regionCode;
            }
        }
        return null;
    }
protected function getRegionCodeForShortNumberFromRegionList(PhoneNumber $number, $regionCodes)
    {
        if (count($regionCodes) == 0) {
            return null;
        }

        if (count($regionCodes) == 1) {
            return $regionCodes[0];
        }

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

        foreach ($regionCodes as $regionCode) {
            $phoneMetadata = $this->getMetadataForRegion($regionCode);
            if ($phoneMetadata !== null
                && $this->matchesPossibleNumberAndNationalNumber($nationalNumber, $phoneMetadata->getShortCode())
            ) {
                // The number is valid for this region.
                return $regionCode;
            }
        }
        return null;
    }
protected function getRegionCodeForShortNumberFromRegionList ( PhoneNumber $ number , $ regionCodes ) { if ( count ( $ regionCodes ) == 0 ) { return null ; } if ( count ( $ regionCodes ) == 1 ) { return $ regionCodes [ 0 ] ; } $ nationalNumber = $ this -> getNationalSignificantNumber ( $ number ) ; foreach ( $ regionCodes as $ regionCode ) { $ phoneMetadata = $ this -> getMetadataForRegion ( $ regionCode ) ; if ( $ phoneMetadata !== null && $ this -> matchesPossibleNumberAndNationalNumber ( $ nationalNumber , $ phoneMetadata -> getShortCode ( ) ) ) { // The number is valid for this region. return $ regionCode ; } } return null ; }
Helper method to get the region code for a given phone number, from a list of possible region
codes. If the list contains more than one region, the first region for which the number is
valid is returned.

@param PhoneNumber $number
@param $regionCodes
@return String|null Region Code (or null if none are found)
Helper method to get the region code for a given phone number from a list of possible region codes . If the list contains more than one region the first region for which the number is valid is returned .