alphaolomi / tz-phone-number
This is my package tz-phone-number
Fund package maintenance!
Patreon
Requires
- php: ^7.4|^8.1
Requires (Dev)
- laravel/pint: ^1.2
- pestphp/pest: ^1.20
This package is auto-updated.
Last update: 2024-12-26 04:20:47 UTC
README
A PHP package to validate and format Tanzanian phone numbers. It uses the Tanzania Communications Regulatory Authority Schema to reconcile and validate the phone number and get the network operator.
Installation
You can install the package via composer:
composer require alphaolomi/tz-phone-number
Usage
use Alphaolomi\TzPhoneNumber\PhoneNumber; $phoneNumber = new PhoneNumber('255 754 123 456'); // To get the country code $phoneNumber->getCountryCode(); // 255 // To get the Network Operator $phoneNumber->getNetworkOperator(); // Vodacom // To check if the phone number is valid $phoneNumber->isValid(); // true // To get the phone number in international format $phoneNumber->getNumber(); // +255754123456 // To get the phone number in local format $phoneNumber->getLocalNumber(); // -754123456
Caveats
- The phone number must be in the format
255 754 123 456
or754 123 456
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Reference
Credits
License
The MIT License (MIT). Please see License File for more information.