當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhoneNumberUtil::getExampleNumberForType方法代碼示例

本文整理匯總了PHP中libphonenumber\PhoneNumberUtil::getExampleNumberForType方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhoneNumberUtil::getExampleNumberForType方法的具體用法?PHP PhoneNumberUtil::getExampleNumberForType怎麽用?PHP PhoneNumberUtil::getExampleNumberForType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在libphonenumber\PhoneNumberUtil的用法示例。


在下文中一共展示了PhoneNumberUtil::getExampleNumberForType方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkNumbersValidAndCorrectType

 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}");
     }
 }
開發者ID:gnovaro,項目名稱:libphonenumber-for-php,代碼行數:10,代碼來源:ExampleNumbersTest.php

示例2: testLocales

 /**
  * @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}");
 }
開發者ID:wakeless,項目名稱:libphonenumber-for-php,代碼行數:15,代碼來源:LocaleTest.php

示例3: testGetExampleNumber

 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));
 }
開發者ID:wasabiNorman,項目名稱:libphonenumber-for-php,代碼行數:15,代碼來源:PhoneNumberUtilTest.php


注:本文中的libphonenumber\PhoneNumberUtil::getExampleNumberForType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。