Created
August 19, 2016 17:29
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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