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) {
}
}
// 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) {
}
return null;
}