libphonenumber\PhoneNumberUtil::getExampleNumber PHP Method

getExampleNumber() public method

Gets a valid number for the specified region.
public getExampleNumber ( $regionCode ) : PhoneNumber
return PhoneNumber a valid fixed-line number for the specified region. Returns null when the metadata does not contain such information, or the region 001 is passed in. For 001 (representing non-geographical numbers), call {@link #getExampleNumberForNonGeoEntity} instead.
    public function getExampleNumber($regionCode)
    {
        return $this->getExampleNumberForType($regionCode, PhoneNumberType::FIXED_LINE);
    }

Usage Example

示例#1
0
文件: Phone.php 项目: iPublikuj/phone
 /**
  * @param string $country
  * @param string $format
  *
  * @return string|NULL
  *
  * @throws Exceptions\NoValidCountryException
  */
 protected function getExampleNumber($country, $format)
 {
     // Check if country is valid
     $country = $this->validateCountry($country);
     // Create example number
     $number = $this->phoneNumberUtil->getExampleNumber($country);
     return $number !== NULL ? $this->phoneNumberUtil->format($number, $format) : NULL;
 }
All Usage Examples Of libphonenumber\PhoneNumberUtil::getExampleNumber
PhoneNumberUtil