src/PhoneNumberUtil.php
public function getExampleNumberForType($regionCodeOrType, $type = null)
    {
        if ($regionCodeOrType !== null && $type === null) {
            /*
             * Gets a valid number for the specified number type (it may belong to any country).
             */
            foreach ($this->getSupportedRegions() as $regionCode) {
                $exampleNumber = $this->getExampleNumberForType($regionCode, $regionCodeOrType);
                if ($exampleNumber !== null) {
                    return $exampleNumber;
                }
            }

            // If there wasn't an example number for a region, try the non-geographical entities
            foreach ($this->getSupportedGlobalNetworkCallingCodes() as $countryCallingCode) {
                $desc = $this->getNumberDescByType($this->getMetadataForNonGeographicalRegion($countryCallingCode), $regionCodeOrType);
                try {
                    if ($desc->getExampleNumber() != '') {
                        return $this->parse('+' . $countryCallingCode . $desc->getExampleNumber(), static::UNKNOWN_REGION);
                    }
                } catch (NumberParseException $e) {
                    // noop
                }
            }
            // There are no example numbers of this type for any country in the library.
            return null;
        }

        // Check the region code is valid.
        if (!$this->isValidRegionCode($regionCodeOrType)) {
            return null;
        }
        $desc = $this->getNumberDescByType($this->getMetadataForRegion($regionCodeOrType), $type);
        try {
            if ($desc->hasExampleNumber()) {
                return $this->parse($desc->getExampleNumber(), $regionCodeOrType);
            }
        } catch (NumberParseException $e) {
            // noop
        }
        return null;
    }
public function getExampleNumberForType($regionCodeOrType, $type = null)
    {
        if ($regionCodeOrType !== null && $type === null) {
            /*
             * Gets a valid number for the specified number type (it may belong to any country).
             */
            foreach ($this->getSupportedRegions() as $regionCode) {
                $exampleNumber = $this->getExampleNumberForType($regionCode, $regionCodeOrType);
                if ($exampleNumber !== null) {
                    return $exampleNumber;
                }
            }

            // If there wasn't an example number for a region, try the non-geographical entities
            foreach ($this->getSupportedGlobalNetworkCallingCodes() as $countryCallingCode) {
                $desc = $this->getNumberDescByType($this->getMetadataForNonGeographicalRegion($countryCallingCode), $regionCodeOrType);
                try {
                    if ($desc->getExampleNumber() != '') {
                        return $this->parse('+' . $countryCallingCode . $desc->getExampleNumber(), static::UNKNOWN_REGION);
                    }
                } catch (NumberParseException $e) {
                    // noop
                }
            }
            // There are no example numbers of this type for any country in the library.
            return null;
        }

        // Check the region code is valid.
        if (!$this->isValidRegionCode($regionCodeOrType)) {
            return null;
        }
        $desc = $this->getNumberDescByType($this->getMetadataForRegion($regionCodeOrType), $type);
        try {
            if ($desc->hasExampleNumber()) {
                return $this->parse($desc->getExampleNumber(), $regionCodeOrType);
            }
        } catch (NumberParseException $e) {
            // noop
        }
        return null;
    }
public function getExampleNumberForType ( $ regionCodeOrType , $ type = null ) { if ( $ regionCodeOrType !== null && $ type === null ) { /*
             * Gets a valid number for the specified number type (it may belong to any country).
             */ foreach ( $ this -> getSupportedRegions ( ) as $ regionCode ) { $ exampleNumber = $ this -> getExampleNumberForType ( $ regionCode , $ regionCodeOrType ) ; if ( $ exampleNumber !== null ) { return $ exampleNumber ; } } // If there wasn't an example number for a region, try the non-geographical entities foreach ( $ this -> getSupportedGlobalNetworkCallingCodes ( ) as $ countryCallingCode ) { $ desc = $ this -> getNumberDescByType ( $ this -> getMetadataForNonGeographicalRegion ( $ countryCallingCode ) , $ regionCodeOrType ) ; try { if ( $ desc -> getExampleNumber ( ) != '' ) { return $ this -> parse ( '+' . $ countryCallingCode . $ desc -> getExampleNumber ( ) , static :: UNKNOWN_REGION ) ; } } catch ( NumberParseException $ e ) { // noop } } // There are no example numbers of this type for any country in the library. return null ; } // Check the region code is valid. if ( ! $ this -> isValidRegionCode ( $ regionCodeOrType ) ) { return null ; } $ desc = $ this -> getNumberDescByType ( $ this -> getMetadataForRegion ( $ regionCodeOrType ) , $ type ) ; try { if ( $ desc -> hasExampleNumber ( ) ) { return $ this -> parse ( $ desc -> getExampleNumber ( ) , $ regionCodeOrType ) ; } } catch ( NumberParseException $ e ) { // noop } return null ; }
Gets a valid number for the specified region and number type.

@param string|int $regionCodeOrType the region for which an example number is needed
@param int $type the PhoneNumberType of number that is needed
@return PhoneNumber a valid number for the specified region and type. Returns null when the metadata
does not contain such information or if an invalid region or region 001 was entered.
For 001 (representing non-geographical numbers), call
{@link #getExampleNumberForNonGeoEntity} instead.

If $regionCodeOrType is the only parameter supplied, then a valid number for the specified number type
will be returned that may belong to any country.
Gets a valid number for the specified region and number type .