2017 © Pedro Peláez
 

library e164-phone-number-formatter-bundle

Propertygurus's phone number formatter

image

propertyguru/e164-phone-number-formatter-bundle

Propertygurus's phone number formatter

  • Wednesday, November 25, 2015
  • by devzer01
  • Repository
  • 53 Watchers
  • 2 Stars
  • 392 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

E164-phone-number-formatter-bundle

Symfony2 bundle to format phone numbers in E164 format., (*2)

Installation

Add the repository to your composer.json file, (*3)

``` js // composer.json, (*4)

{ "require": { // ... "propertyguru/E164-phone-number-formatter-bundle" : "dev-master" } }, (*5)


Register the bundle in your AppKernel: ``` php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Guru\PhoneNumberFormatterBundle\GuruPhoneNumberFormatterBundle(), // ... ); }

Usage

Setup, (*6)

$formatter = $this->container->get('guru_phone_number_formatter.formatter');
// optional: set current country - if known
$formatter->setDefaultRegionCode('my');

If you know the country code already, (*7)

$e164 = $formatter->numberToE164('0101234567', '60');

If the country code if embedded in the number, (*8)

$e164 = $formatter->numberToE164('+60101234567');

If you are not sure if the country code is embedded or not, (*9)

$e164 = $formatter->numberToE164('+60101234567', '60');

All of the above will output, (*10)

array(
   'countryCode' => '60',
   'nationalDestinationCode' => '010',
   'nationalDestinationCodeInternational' => '10',
   'subscriberNumber' => '1234567',
   'isMobile' => true,
)

Embedded country code has precedence over specified country code, (*11)

$e164 = $formatter->numberToE164('+65101234567', '60');

and will output:, (*12)

array(
   'countryCode' => '65',
   'nationalDestinationCode' => NULL,
   'nationalDestinationCodeInternational' => NULL,
   'subscriberNumber' => '101234567',
   'isMobile' => false,
)

Weighted results

Weights can be defined that some country codes are preffered over others. If a number can match more than one country, then only the one with the highest weight is considered, (*13)

$formatter->setRegionWeights(array(
    'my' => 1,
    'sg' => 2
));

Example : 98123123 can be either a malaysia or singaporean phone number., (*14)

Contributors

The Versions

25/11 2015

dev-master

9999999-dev

Propertygurus's phone number formatter

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

25/11 2015

v1.0

1.0.0.0

Propertygurus's phone number formatter

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

23/09 2015

dev-SEARCH-2506

dev-SEARCH-2506

Propertygurus's phone number formatter

  Sources   Download