src/geocoding/PhoneNumberOfflineGeocoder.php
protected function getCountryNameForNumber(PhoneNumber $number, $locale)
    {
        $regionCodes = $this->phoneUtil->getRegionCodesForCountryCode($number->getCountryCode());

        if (count($regionCodes) === 1) {
            return $this->getRegionDisplayName($regionCodes[0], $locale);
        }

        $regionWhereNumberIsValid = 'ZZ';
        foreach ($regionCodes as $regionCode) {
            if ($this->phoneUtil->isValidNumberForRegion($number, $regionCode)) {
                // If the number has already been found valid for one region, then we don't know which
                // region it belongs to so we return nothing.
                if ($regionWhereNumberIsValid !== 'ZZ') {
                    return '';
                }
                $regionWhereNumberIsValid = $regionCode;
            }
        }

        return $this->getRegionDisplayName($regionWhereNumberIsValid, $locale);
    }
protected function getCountryNameForNumber(PhoneNumber $number, $locale)
    {
        $regionCodes = $this->phoneUtil->getRegionCodesForCountryCode($number->getCountryCode());

        if (count($regionCodes) === 1) {
            return $this->getRegionDisplayName($regionCodes[0], $locale);
        }

        $regionWhereNumberIsValid = 'ZZ';
        foreach ($regionCodes as $regionCode) {
            if ($this->phoneUtil->isValidNumberForRegion($number, $regionCode)) {
                // If the number has already been found valid for one region, then we don't know which
                // region it belongs to so we return nothing.
                if ($regionWhereNumberIsValid !== 'ZZ') {
                    return '';
                }
                $regionWhereNumberIsValid = $regionCode;
            }
        }

        return $this->getRegionDisplayName($regionWhereNumberIsValid, $locale);
    }
protected function getCountryNameForNumber ( PhoneNumber $ number , $ locale ) { $ regionCodes = $ this -> phoneUtil -> getRegionCodesForCountryCode ( $ number -> getCountryCode ( ) ) ; if ( count ( $ regionCodes ) === 1 ) { return $ this -> getRegionDisplayName ( $ regionCodes [ 0 ] , $ locale ) ; } $ regionWhereNumberIsValid = 'ZZ' ; foreach ( $ regionCodes as $ regionCode ) { if ( $ this -> phoneUtil -> isValidNumberForRegion ( $ number , $ regionCode ) ) { // If the number has already been found valid for one region, then we don't know which // region it belongs to so we return nothing. if ( $ regionWhereNumberIsValid !== 'ZZ' ) { return '' ; } $ regionWhereNumberIsValid = $ regionCode ; } } return $ this -> getRegionDisplayName ( $ regionWhereNumberIsValid , $ locale ) ; }
Returns the customary display name in the given language for the given territory the phone
number is from. If it could be from many territories, nothing is returned.

@param PhoneNumber $number
@param string $locale
@return string
Returns the customary display name in the given language for the given territory the phone number is from . If it could be from many territories nothing is returned .