joemags-apps / zim-phone-utils
A Laravel package for working with phone numbers in the Zimbabwean context.
Fund package maintenance!
Joe Munapo
Requires
- php: ^8.1
- giggsey/libphonenumber-for-php: ^8.13
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
README
Zim Phone Utils is a Laravel package that provides a set of utility functions and custom validation rules for working with phone numbers in the Zimbabwean context. It simplifies tasks such as formatting phone numbers, extracting country codes, determining mobile carriers, and validating phone numbers against specific criteria.
Features
- Format phone numbers in national or international format
- Extract country ISO codes and country codes from phone numbers
- Determine the mobile carrier for a given phone number
- Custom validation rules for phone numbers and mobile carriers
- Seamless integration with Laravel's validation system
Installation
You can install the package via composer:
composer require joemags-apps/zim-phone-utils
Usage
use JoemagsApps\ZimPhoneUtils\Utils; // Format a phone number $formattedNumber = Utils::formatPhoneNumber('+263771234567'); // Get the country ISO code $countryIso = Utils::getCountryIso('+263771234567'); // Get the mobile carrier $carrier = Utils::getPhoneCarrier('+263771234567'); // Validate a phone number $request->validate([ 'phone' => 'required|phone:ZW', ]); // Validate a mobile carrier $request->validate([ 'carrier' => 'required|carrier:Econet,NetOne,Telecel', ]);
Testing
composer test # Run tests
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.
Credits
License
The MIT License (MIT). Please see License File for more information.