This is a simple php class that formats Kenyan phone Numbers and identifies which carrier the number is on.
Instantiate the class or extend on your methods
$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;
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;
}
}
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.
Format the Phone number, and pass the formatted number to the method check_operator()
Operators include:
- Safaricom
- Airtel
- Equitel
- Telkom
- JTL
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.
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.