leadsolution/phone-number-normalizer

Normalizes Brazilian Phone Numbers.

Installs: 169

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 0

Forks: 1

Open Issues: 1

pkg:composer/leadsolution/phone-number-normalizer

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

This package is auto-updated.

Last update: 2025-09-10 11:50:23 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