| Conditions | 7 |
| Paths | 5 |
| Total Lines | 20 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | private function cleanPhone($phone) |
||
| 37 | { |
||
| 38 | $absolute = $phone[0] === '+'; |
||
| 39 | $numbers = preg_replace('/\D/', '', $phone); |
||
| 40 | |||
| 41 | if (!$numbers) { |
||
| 42 | throw new PhoneFormatInvalidException(); |
||
| 43 | } |
||
| 44 | |||
| 45 | // special logic for russian local phone notation |
||
| 46 | if ($numbers[0] === '8' && !$absolute && strlen($numbers) == 11) { |
||
| 47 | $numbers[0] = '7'; |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($numbers[0] !== '7' || strlen($numbers) != 11) { |
||
| 51 | throw new PhoneFormatInvalidException(); |
||
| 52 | } |
||
| 53 | |||
| 54 | return $numbers; |
||
| 55 | } |
||
| 56 | } |
||
| 57 |