1 | <?php |
||
7 | class Msisdn |
||
8 | { |
||
9 | private $msisdn; |
||
10 | |||
11 | private $smartPrefixes = null; |
||
12 | |||
13 | private $globePrefixes = null; |
||
14 | |||
15 | private $sunPrefixes = null; |
||
16 | |||
17 | private $prefix = null; |
||
18 | |||
19 | private $operator = null; |
||
20 | |||
21 | protected $countryPrefix = '+63'; |
||
22 | |||
23 | /** |
||
24 | * Msisdn constructor. |
||
25 | * |
||
26 | * @param $msisdn |
||
27 | * @throws InvalidMsisdnException |
||
28 | */ |
||
29 | 12 | public function __construct($msisdn) |
|
42 | |||
43 | /** |
||
44 | * Returns a formatted mobile number |
||
45 | * |
||
46 | * @param bool|false $hasCountryCode |
||
47 | * @param string $separator |
||
48 | * @return mixed|string |
||
49 | */ |
||
50 | 3 | function get($hasCountryCode = false, $separator = '') |
|
71 | |||
72 | /** |
||
73 | * Returns the prefix of the MSISDN number. |
||
74 | * |
||
75 | * @return string The prefix of the MSISDN number |
||
76 | */ |
||
77 | 6 | public function getPrefix() |
|
85 | |||
86 | /** |
||
87 | * Determines the operator of this number |
||
88 | * |
||
89 | * @return string The operator of this number |
||
90 | */ |
||
91 | 3 | public function getOperator() |
|
121 | |||
122 | 3 | private function setPrefixes() |
|
136 | |||
137 | /** |
||
138 | * Validate a given mobile number |
||
139 | * |
||
140 | * @param string $mobileNumber |
||
141 | * @return bool |
||
142 | */ |
||
143 | 18 | public static function validate($mobileNumber) |
|
151 | |||
152 | /** |
||
153 | * Cleans the string |
||
154 | * |
||
155 | * @param string $msisdn |
||
156 | * @return string The clean MSISDN |
||
157 | */ |
||
158 | 18 | private static function clean($msisdn) |
|
173 | |||
174 | /** |
||
175 | * Sets the country prefix - this defaults to +63 |
||
176 | * |
||
177 | * @param $countryPrefix |
||
178 | */ |
||
179 | public function setCountryPrefix($countryPrefix) |
||
183 | } |
||
184 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.