Skip to content

leadsolution/phone-number-normalizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Phone Number Normalizer CI

๐Ÿ“ž 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).

Install

composer require leadsolution/phone-number-normalizer

Usage examples

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

Removes non-digits

$normalizer->normalize('2345-6789')->toString();
// 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

$normalizer->normalize('987654321')->isMobile();
// true

$normalizer->normalize('23456789')->isMobile();
// false

MIT

About

๐Ÿ“ž Normalizes Brazilian Phone Numbers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages