If the number is not considered possible for the numbering plan of the default region
initially, but starts with the country calling code of this region, validation will be
reattempted after stripping this country calling code. If this number is considered a
possible number, then the first digits will be considered the country calling code and
removed as such.
It will throw a NumberParseException if the number starts with a '+' but the country calling
code supplied after this does not match that of any known region.
public maybeExtractCountryCode ( string $number, |
||
$number | string | non-normalized telephone number that we wish to extract a country calling code from - may begin with '+' |
$defaultRegionMetadata | metadata about the region this number may be from | |
$nationalNumber | string | a string buffer to store the national significant number in, in the case that a country calling code was extracted. The number is appended to any existing contents. If no country calling code was extracted, this will be left unchanged. |
$keepRawInput | boolean | true if the country_code_source and preferred_carrier_code fields of phoneNumber should be populated. |
$phoneNumber | the PhoneNumber object where the country_code and country_code_source need to be populated. Note the country_code is always populated, whereas country_code_source is only populated when keepCountryCodeSource is true. | |
return | integer | the country calling code extracted or 0 if none could be extracted |