Normalizes Brazilian Phone Numbers.

v0.1.1 2020-06-09 23:52 UTC

This package is auto-updated.

Last update: 2022-01-10 03:54:52 UTC


📞 It tries to normalize a phone number from whatever * input it receives.
*(can't do magic, if you got a new case, feel free to open an issue or a PR).


composer require leadsolution/phone-number-normalizer

Usage examples

use Leadsolution\PhoneNumber\Normalizer;
$normalizer = new Normalizer();

Removes non-digits

// 23456789

$normalizer->normalize('(11) 2345-6789')->toString();
// 1123456789 

Adds default national codes

$normalizer->normalize('2345-6789', '11')->toString();
// 1123456789 

Removes international codes

$normalizer->normalize('+55 (11) 2345-6789')->toString();
// 1123456789 

Adds the 9 digit on mobile numbers

$normalizer->normalize('7345-6789', '11')->toString();
// 11973456789 

Checks if the returned object is a mobile

// true

// false