Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MobileNumberClassifier return the carrier of the phone number. e.g. NTC, NCELL etc. (For Nepal)
<?php
/**
* @Author Bhaktaraz Bhatta <bhattabhakta@gmail.com>
*/
namespace SMS\Bundle\MainBundle\Services;
/**
* MobileNumberClassifier return the carrier of the phone number. e.g. NTC, NCELL etc.
*/
class MobileNumberClassifier
{
/**
* @param $mobileNumber
* @return string
*/
public function getMobileNumberCarrier($mobileNumber)
{
$firstThreeNumbers = substr($mobileNumber, 0, 3);
$ncellFirstThreeNumbers = ['980', '981', '982'];
$ntcFirstThreeNumbers = ['984', '985', '985'];
if (in_array($firstThreeNumbers, $ntcFirstThreeNumbers)) {
return 'NTC';
}
if (in_array($firstThreeNumbers, $ncellFirstThreeNumbers)) {
return 'NCELL';
}
return 'UNKNOWN';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment