PHPackages                             alphaolomi/tz-phone-number - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alphaolomi/tz-phone-number

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

alphaolomi/tz-phone-number
==========================

This is my package tz-phone-number

v1.0.0-beta(2y ago)1011[4 PRs](https://github.com/alphaolomi/tz-phone-number/pulls)MITPHPPHP ^7.4|^8.1CI passing

Since Jun 24Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/alphaolomi/tz-phone-number)[ Packagist](https://packagist.org/packages/alphaolomi/tz-phone-number)[ Docs](https://github.com/alphaolomi/tz-phone-number)[ Patreon](https://www.patreon.com/alphaolomi)[ RSS](/packages/alphaolomi-tz-phone-number/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (6)Used By (0)

Tanzania Lib Phone Number
=========================

[](#tanzania-lib-phone-number)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ea2137842ec2f2e9c01c68235711147d47750dba830fb1baf5649d6477cb3d91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c7068616f6c6f6d692f747a2d70686f6e652d6e756d6265722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alphaolomi/tz-phone-number)[![Tests](https://camo.githubusercontent.com/342551213dce07f1cb8162e6da2d259d910b0e3cef378afc03826f75988f1444/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c7068616f6c6f6d692f747a2d70686f6e652d6e756d6265722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/alphaolomi/tz-phone-number/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/149099e2a31fc2af976a362fc6232293c9b1f9721b7e9d1c74b7ad84f15386cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c7068616f6c6f6d692f747a2d70686f6e652d6e756d6265722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alphaolomi/tz-phone-number)

A PHP package to validate and format Tanzanian phone numbers. It uses the [Tanzania Communications Regulatory Authority](https://www.tcra.go.tz/) Schema to reconcile and validate the phone number and get the network operator.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require alphaolomi/tz-phone-number
```

Usage
-----

[](#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
-------

[](#caveats)

- The phone number must be in the format `255 754 123 456` or `754 123 456`

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Reference
---------

[](#reference)

- [Summary of Tanzania Numbering Plan](https://gist.github.com/alphaolomi/27c8daf8655768fe9991749cc67dd77d)
- [TCRA Ref. of of Tanzania Numbering Plan Doc.](https://nms.tcra.go.tz/nms/auvit/National_Numbering_Plan.pdf)

Credits
-------

[](#credits)

- [Alpha Olomi](https://github.com/alphaolomi)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance52

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1053d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7534dd7341d883267be41935354b56c27f94d6bbd6a7abd9f257bb2d494a3798?d=identicon)[alphao](/maintainers/alphao)

---

Top Contributors

[![alphaolomi](https://avatars.githubusercontent.com/u/10551599?v=4)](https://github.com/alphaolomi "alphaolomi (11 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

phone-numberalphaolomitz-phone-number

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/alphaolomi-tz-phone-number/health.svg)

```
[![Health](https://phpackages.com/badges/alphaolomi-tz-phone-number/health.svg)](https://phpackages.com/packages/alphaolomi-tz-phone-number)
```

###  Alternatives

[odolbeau/phone-number-bundle

Integrates libphonenumber into your Symfony application

24910.3M11](/packages/odolbeau-phone-number-bundle)[log1x/acf-phone-number

A real ACF phone number field.

12072.5k](/packages/log1x-acf-phone-number)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
