| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | private function setPhone(string $phone): void |
||
| 39 | { |
||
| 40 | $phone = preg_replace('/[^0-9]/', '', $phone); |
||
| 41 | if (strlen($phone) < 10) { |
||
| 42 | throw new ShortPhoneException('Phone number too short. Minimum 10 numbers'); |
||
| 43 | } elseif (strlen($phone) == 10) { |
||
| 44 | $phone = '+7' . $phone; |
||
| 45 | } elseif (strlen($phone) > 11) { |
||
| 46 | throw new LongPhoneException('Phone number too long. Maximum 11 numbers without symbol `+`'); |
||
| 47 | } else { |
||
| 48 | $phone = '+' . $phone; |
||
| 49 | } |
||
| 50 | |||
| 51 | |||
| 52 | $this->phone= '+7 (' . substr($phone, -10, 3) . ') ' . substr($phone, -7, 3) . '-' . substr($phone, -4, 2) . '-' . substr($phone, -2); |
||
| 53 | } |
||
| 55 | } |