Skip to content

Format Kenyan Phone Numbers, classify them based on ISP and add prefixes automatically

Notifications You must be signed in to change notification settings

wheezyy/format-kenyan-phone-numbers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Phone Number Formatter

This is a simple php class that formats Kenyan phone Numbers and identifies which carrier the number is on.

Usage

Instantiate the class or extend on your methods

Instantiating

       $newClass = new Identifier;

       // your logic

       # Format phone numbers
       $formatted_number = $newClass->formatted_phone_number('0711 123 456');
       echo $formatted_number;

       # Check ISP
       $isp = $newClass->check_operator($formatted_number);
       echo $isp;

Extending

 class YourClassName extends Identifier{
     // your logic

     public function your_method(){

         # Format phone numbers
        $formatted_number = $this->formatted_phone_number('0711 123 456');
        echo $formatted_number;

        # Check ISP
        $isp = $this->check_operator($formatted_number);
        echo $isp;
     }
 }

Format Phone Numbers

Pass the phone number in any format to the method format_phone_number($param) where the $param is the phone number you wish to format.

Check Operator(ISP)

Format the Phone number, and pass the formatted number to the method check_operator()

Operators include:

  • Safaricom
  • Airtel
  • Equitel
  • Telkom
  • JTL

Contribution

This is a work in progress and contributions are highly welcome. You can submit a PR anytime and once we review we might merge or advice.

License Information

This piece of code is offered under MIT licence. Feel free to use for personal or commercial projects.

We are not responsible for misuse, loss or damages caused or incurred or accrued as a result of usage of this piece of code.

About

Format Kenyan Phone Numbers, classify them based on ISP and add prefixes automatically

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%