Skip to content

Instantly share code, notes, and snippets.

@bhaktaraz
Created August 19, 2016 17:29
Show Gist options
  • Save bhaktaraz/9678a08dca7b7edd2d495dffca7faf69 to your computer and use it in GitHub Desktop.
Save bhaktaraz/9678a08dca7b7edd2d495dffca7faf69 to your computer and use it in GitHub Desktop.
MobileNumberClassifier return the carrier of the phone number. e.g. NTC, NCELL etc. (For Nepal)
<?php
/**
* @Author Bhaktaraz Bhatta <[email protected]>
*/
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