Skip to content

Commit

Permalink
Merge pull request #7 from giggsey/google_5.8.2
Browse files Browse the repository at this point in the history
Google 5.8.4
  • Loading branch information
giggsey committed Sep 20, 2013
2 parents d43e54c + 5a4a97c commit ef005af
Show file tree
Hide file tree
Showing 541 changed files with 1,849 additions and 612 deletions.
8 changes: 8 additions & 0 deletions Tests/PhoneNumberUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ public function testGetLengthOfNationalDestinationCode()
$this->assertEquals(4, $this->phoneUtil->getLengthOfNationalDestinationCode(self::$internationalTollFree));
}

public function testGetCountryMobileToken()
{
$this->assertEquals("1", $this->phoneUtil->getCountryMobileToken($this->phoneUtil->getCountryCodeForRegion(RegionCode::MX)));

// Country calling code for Sweden, which has no mobile token.
$this->assertEquals("", $this->phoneUtil->getCountryMobileToken($this->phoneUtil->getCountryCodeForRegion(RegionCode::SE)));
}

public function testGetNationalSignificantNumber()
{
$this->assertEquals("6502530000", $this->phoneUtil->getNationalSignificantNumber(self::$usNumber));
Expand Down
4 changes: 2 additions & 2 deletions Tests/ShortNumberInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ public function testGetExampleShortNumberForCost()
$this->shortInfo->getExampleShortNumberForCost(RegionCode::FR, ShortNumberCost::TOLL_FREE)
);
$this->assertEquals(
"118777",
"1023",
$this->shortInfo->getExampleShortNumberForCost(RegionCode::FR, ShortNumberCost::STANDARD_RATE)
);
$this->assertEquals(
"3200",
"42000",
$this->shortInfo->getExampleShortNumberForCost(RegionCode::FR, ShortNumberCost::PREMIUM_RATE)
);
$this->assertEquals(
Expand Down
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_800.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => true,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_979.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_AD.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_AE.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_AO.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_AR.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_AU.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_BR.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_BS.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_BY.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_DE.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_GB.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_GG.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_IT.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => true,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_JP.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => true,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_KR.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_MX.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_NZ.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_PL.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_RE.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@
'mainCountryForCode' => NULL,
'leadingDigits' => '262|6(?:9[23]|47)|8',
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_SG.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,6 @@
),
'mainCountryForCode' => NULL,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_US.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,6 @@
),
'mainCountryForCode' => true,
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
1 change: 1 addition & 0 deletions Tests/data/PhoneNumberMetadataForTesting_YT.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,6 @@
'mainCountryForCode' => NULL,
'leadingDigits' => '269|639',
'leadingZeroPossible' => NULL,
'mobileNumberPortableRegion' => NULL,
);
/* EOF */
10 changes: 8 additions & 2 deletions build/BuildMetadataFromXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class BuildMetadataFromXml
const INTL_FORMAT = "intlFormat";
const LEADING_DIGITS = "leadingDigits";
const LEADING_ZERO_POSSIBLE = "leadingZeroPossible";
const MOBILE_NUMBER_PORTABLE_REGION = "mobileNumberPortableRegion";
const MAIN_COUNTRY_FOR_CODE = "mainCountryForCode";
const MOBILE = "mobile";
const NATIONAL_NUMBER_PATTERN = "nationalNumberPattern";
Expand Down Expand Up @@ -191,6 +192,9 @@ private static function loadTerritoryTagMetadata(
if ($element->hasAttribute(self::LEADING_ZERO_POSSIBLE)) {
$metadata->setLeadingZeroPossible(true);
}
if ($element->hasAttribute(self::MOBILE_NUMBER_PORTABLE_REGION)) {
$metadata->setMobileNumberPortableRegion(true);
}
return $metadata;
}

Expand Down Expand Up @@ -369,7 +373,9 @@ private static function loadGeneralDesc(PhoneMetadata $metadata, \DOMElement $el
$metadata->setUan(self::processPhoneNumberDescElement($generalDesc, $element, self::UAN));
$metadata->setEmergency(self::processPhoneNumberDescElement($generalDesc, $element, self::EMERGENCY));
$metadata->setVoicemail(self::processPhoneNumberDescElement($generalDesc, $element, self::VOICEMAIL));
$metadata->setCarrierSpecific(self::processPhoneNumberDescElement($generalDesc, $element, self::CARRIER_SPECIFIC));
$metadata->setCarrierSpecific(
self::processPhoneNumberDescElement($generalDesc, $element, self::CARRIER_SPECIFIC)
);


$metadata->setNoInternationalDialling(
Expand Down Expand Up @@ -452,7 +458,7 @@ public static function buildCountryCodeToRegionCodeMap($metadataCollection)
$countryCode = $metadata->getCountryCode();
if (array_key_exists($countryCode, $countryCodeToRegionCodeMap)) {
if ($metadata->getMainCountryForCode()) {
array_unshift( $countryCodeToRegionCodeMap[$countryCode], $regionCode);
array_unshift($countryCodeToRegionCodeMap[$countryCode], $regionCode);
} else {
$countryCodeToRegionCodeMap[$countryCode][] = $regionCode;
}
Expand Down
7 changes: 4 additions & 3 deletions src/libphonenumber/AlternateFormatsCountryCodeSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class AlternateFormatsCountryCodeSet {
20 => 380,
21 => 385,
22 => 595,
23 => 855,
24 => 971,
25 => 972,
23 => 675,
24 => 855,
25 => 971,
26 => 972,
);

}
Expand Down
19 changes: 19 additions & 0 deletions src/libphonenumber/PhoneMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@ public function setLeadingZeroPossible($value) {
return $this;
}

private $mobileNumberPortableRegion = null;

public function hasMobileNumberPortableRegion() {
return isset($this->mobileNumberPortableRegion);
}

public function isMobileNumberPortableRegion() {
return $this->mobileNumberPortableRegion;
}

public function setMobileNumberPortableRegion($value) {
$this->mobileNumberPortableRegion = $value;
return $this;
}

private $generalDesc = null;

public function hasGeneralDesc() {
Expand Down Expand Up @@ -644,6 +659,8 @@ public function toArray() {

$output['leadingZeroPossible'] = $this->isLeadingZeroPossible();

$output['mobileNumberPortableRegion'] = $this->isMobileNumberPortableRegion();

return $output;
}

Expand Down Expand Up @@ -783,6 +800,8 @@ public function fromArray(array $input) {

$this->setLeadingZeroPossible($input['leadingZeroPossible']);

$this->setMobileNumberPortableRegion($input['mobileNumberPortableRegion']);

return $this;
}

Expand Down
Loading

0 comments on commit ef005af

Please sign in to comment.