public getExampleShortNumber ( $regionCode ) : string | ||
$regionCode | String the region for which an example short number is needed | |
return | string | a valid short number for the specified region. Returns an empty string when the metadata does not contain such information. |
public function getExampleShortNumber($regionCode)
{
$phoneMetadata = $this->getMetadataForRegion($regionCode);
if ($phoneMetadata === null) {
return "";
}
/** @var PhoneNumberDesc $desc */
$desc = $phoneMetadata->getShortCode();
if ($desc !== null && $desc->hasExampleNumber()) {
return $desc->getExampleNumber();
}
return "";
}
public function testGetExampleShortNumber() { $this->assertEquals("8711", $this->shortInfo->getExampleShortNumber(RegionCode::AM)); $this->assertEquals("1010", $this->shortInfo->getExampleShortNumber(RegionCode::FR)); $this->assertEquals("", $this->shortInfo->getExampleShortNumber(RegionCode::UN001)); $this->assertEquals("", $this->shortInfo->getExampleShortNumber(null)); }