alphaolomi/tz-phone-number

This is my package tz-phone-number

v1.0.0-beta 2023-06-24 21:52 UTC

This package is auto-updated.

Last update: 2024-10-26 03:46:35 UTC


README

Latest Version on Packagist Tests Total Downloads

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 or 754 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.