This package aims at providing an easy to use telephone data-type class.
Install via composer - In the terminal:
composer require zenapply/php-telephone
use Zenapply\DataTypes\Telephone;
$phone = new Telephone('+1 (230) 555-3333', 'US'); // The second parameter (region) is optional and defaults to 'US'.
echo $phone . PHP_EOL; // +12305553333
echo $phone->getE164() . PHP_EOL; // +12305553333
echo $phone->getRFC3966() . PHP_EOL; // tel:+1-230-555-3333
echo $phone->getNational() . PHP_EOL; // (230) 555-3333
echo $phone->getInternational() . PHP_EOL; // +1 230-555-3333
echo $phone->getOriginal() . PHP_EOL; // +1 (230) 555-3333
echo $phone->getAreaCode() . PHP_EOL; // 230
echo $phone->getCountryCode() . PHP_EOL; // 1
echo $phone->getSubscriberCode() . PHP_EOL; // 5553333
echo $phone->isValid() . PHP_EOL; // true
Contributions are always welcome!