libphonenumber\ShortNumberInfo::getExampleShortNumber PHP 메소드

getExampleShortNumber() 공개 메소드

Gets a valid short number for the specified region.
public getExampleShortNumber ( $regionCode ) : string
$regionCode String the region for which an example short number is needed
리턴 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 "";
    }

Usage Example

 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));
 }
All Usage Examples Of libphonenumber\ShortNumberInfo::getExampleShortNumber