File: PhoneNumberToCarrierMapper.md

package info (click to toggle)
php-giggsey-libphonenumber 9.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,464 kB
  • sloc: php: 484,879; sh: 107; makefile: 37
file content (28 lines) | stat: -rw-r--r-- 947 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# PhoneNumberToCarrierMapper

## Getting Started

As with [PhoneNumberUtil](PhoneNumberUtil.md), the Phone Number Carrier Mapper uses a singleton.

```php
$carrierMapper = \libphonenumber\PhoneNumberToCarrierMapper::getInstance();
```

## `getNameForNumber()`

Returns the name of the carrier for the supplied `PhoneNumber` object within the `$language` supplied.

```php
$chNumber = \libphonenumber\PhoneNumberUtil::getInstance()->parse("798765432", "CH");

var_dump($carrierMapper->getNameForNumber($chNumber, 'en'));
// string(8) "Swisscom"
```

## `getNameForValidNumber()`

Returns the same as `getNameForNumber()` without checking whether it is a valid number for carrier mapping.

## `getSafeDisplayName()`

Returns the same as `getNameForNumber()`, but only if the number is safe for carrier mapping. A number is only validate for carrier mapping if it's a Mobile or Fixed line, and the country does not support Mobile Number Portability.