leadsolution / phone-number-normalizer
Normalizes Brazilian Phone Numbers.
v0.1.1
2020-06-09 23:52 UTC
Requires (Dev)
- phpunit/phpunit: ^9.2
This package is auto-updated.
Last update: 2024-12-10 09:58:54 UTC
README
📞 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