Property | Type | Description | |
---|---|---|---|
$instance | |||
$phoneUtil | |||
$prefixFileReader |
Method | Description | |
---|---|---|
getInstance ( string $mappingDir = self::MAPPING_DATA_DIRECTORY ) : |
Gets a {@link PhoneNumberToCarrierMapper} instance to carry out international carrier lookup. | |
getNameForNumber ( |
Gets the name of the carrier for the given phone number, in the language provided. As per {@link #getNameForValidNumber(PhoneNumber, Locale)} but explicitly checks the validity of the number passed in. | |
getNameForValidNumber ( |
Returns a carrier name for the given phone number, in the language provided. The carrier name is the one the number was originally allocated to, however if the country supports mobile number portability the number might not belong to the returned carrier anymore. If no mapping is found an empty string is returned. | |
getSafeDisplayName ( |
Gets the name of the carrier for the given phone number only when it is 'safe' to display to users. A carrier name is considered safe if the number is valid and for a region that doesn't support {@linkplain http://en.wikipedia.org/wiki/Mobile_number_portability mobile number portability}. |
Method | Description | |
---|---|---|
__construct ( $phonePrefixDataDirectory ) | ||
isMobile ( integer $numberType ) : boolean | Checks if the supplied number type supports carrier lookup. |
The {@link PhoneNumberToCarrierMapper} is implemented as a singleton. Therefore, calling this method multiple times will only result in one instance being created.
public static getInstance ( string $mappingDir = self::MAPPING_DATA_DIRECTORY ) : |
||
$mappingDir | string | |
return |
public getNameForNumber ( |
||
$number | The phone number for which we want to get a carrier name | |
$languageCode | string | Language code for which the description should be written |
return | string | a carrier name for the given phone number, or empty string if the number passed in is invalid |
This method assumes the validity of the number passed in has already been checked, and that the number is suitable for carrier lookup. We consider mobile and pager numbers possible candidates for carrier lookup.
public getNameForValidNumber ( |
||
$number | a valid phone number for which we want to get a carrier name | |
$languageCode | string | the language code in which the name should be written |
return | string | a carrier name for the given phone number |
public getSafeDisplayName ( |
||
$number | PhoneNumber the phone number for which we want to get a carrier name | |
$languageCode | String the language code in which the name should be written | |
return | string | a carrier name that is safe to display to users, or the empty string |
protected static PhoneNumberToCarrierMapper[],libphonenumber $instance | ||
return |
protected PhoneNumberUtil,libphonenumber $phoneUtil | ||
return |