getExampleNumberForType() public method

Gets a valid number for the specified region and number type.
public getExampleNumberForType ( string | integer $regionCodeOrType, integer $type = null ) : PhoneNumber
$regionCodeOrType string | integer the region for which an example number is needed
$type integer 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.
 private function checkNumbersValidAndCorrectType($exampleNumberRequestedType, $possibleExpectedTypes, $regionCode)
 {
     $exampleNumber = $this->phoneNumberUtil->getExampleNumberForType($regionCode, $exampleNumberRequestedType);
     if ($exampleNumber !== null) {
         $this->assertTrue($this->phoneNumberUtil->isValidNumber($exampleNumber), "Failed validation for {$exampleNumber}");
         // We know the number is valid, now we check the type.
         $exampleNumberType = $this->phoneNumberUtil->getNumberType($exampleNumber);
         $this->assertContains($exampleNumberType, $possibleExpectedTypes, "Wrong type for {$exampleNumber}");
     }
 }
 /**
  * @dataProvider localeList
  * @param string $regionCode
  * @param string $countryName
  */
 public function testLocales($regionCode, $countryName)
 {
     if (!in_array($regionCode, $this->phoneUtil->getSupportedRegions())) {
         $this->markTestSkipped("{$regionCode} is not supported");
     }
     $phoneNumber = $this->phoneUtil->getExampleNumberForType($regionCode, PhoneNumberType::FIXED_LINE_OR_MOBILE);
     $this->assertContains($regionCode, CountryCodeToRegionCodeMap::$countryCodeToRegionCodeMap[$phoneNumber->getCountryCode()]);
     $this->assertEquals($regionCode, $this->phoneUtil->getRegionCodeForNumber($phoneNumber));
     $this->assertEquals($countryName, $this->geocoder->getDescriptionForValidNumber($phoneNumber, 'en', 'ZZ'), "Checking {$phoneNumber} is part of {$countryName}");
 }
 public function testGetExampleNumber()
 {
     $this->assertEquals(self::$deNumber, $this->phoneUtil->getExampleNumber(RegionCode::DE));
     $this->assertEquals(self::$deNumber, $this->phoneUtil->getExampleNumberForType(RegionCode::DE, PhoneNumberType::FIXED_LINE));
     $this->assertEquals(null, $this->phoneUtil->getExampleNumberForType(RegionCode::DE, PhoneNumberType::MOBILE));
     // For the US, the example number is placed under general description, and hence should be used
     // for both fixed line and mobile, so neither of these should return null.
     $this->assertNotNull($this->phoneUtil->getExampleNumberForType(RegionCode::US, PhoneNumberType::FIXED_LINE));
     $this->assertNotNull($this->phoneUtil->getExampleNumberForType(RegionCode::US, PhoneNumberType::MOBILE));
     // CS is an invalid region, so we have no data for it.
     $this->assertNull($this->phoneUtil->getExampleNumberForType(RegionCode::CS, PhoneNumberType::MOBILE));
     // RegionCode 001 is reserved for supporting non-geographical country calling code. We don't
     // support getting an example number for it with this method.
     $this->assertEquals(null, $this->phoneUtil->getExampleNumber(RegionCode::UN001));
 }