| Conditions | 18 |
| Paths | 7 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 18 | public static function getOperator(string $phone): int |
||
| 19 | { |
||
| 20 | $phone = self::getPhoneWithoutPrefix(trim($phone)); |
||
| 21 | |||
| 22 | if(strlen($phone) !== 9) return self::UNKOWN; |
||
| 23 | if (startsWith($phone, '69')) { |
||
| 24 | return self::ORANGE; |
||
| 25 | } |
||
| 26 | if ( |
||
| 27 | startsWith($phone, '655') || startsWith($phone, '656') || startsWith($phone, '657') |
||
| 28 | || startsWith($phone, '658') || startsWith($phone, '659') |
||
| 29 | ) { |
||
| 30 | return self::ORANGE; |
||
| 31 | } |
||
| 32 | if (startsWith($phone, '67')) |
||
| 33 | return self::MTN; |
||
| 34 | if ( |
||
| 35 | startsWith($phone, '650') || startsWith($phone, '651') || startsWith($phone, '652') |
||
| 36 | || startsWith($phone, '653') || startsWith($phone, '654') || startsWith($phone, '680') || startsWith($phone, '681') |
||
| 37 | || startsWith($phone, '682') |
||
| 38 | ) { |
||
| 39 | return self::MTN; |
||
| 40 | } |
||
| 41 | if (startsWith($phone, '66')) |
||
| 42 | return self::NEXTTEL; |
||
| 43 | return self::UNKOWN; |
||
| 44 | } |
||
| 45 | /** |
||
| 67 |