| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | /** |
||
| 18 | * @param $phone |
||
| 19 | * @return string |
||
| 20 | */ |
||
| 21 | public static function format($phone) |
||
| 22 | { |
||
| 23 | if (preg_match('/^(\d{1})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches)) |
||
| 24 | return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5]; |
||
| 25 | |||
| 26 | if (preg_match('/^(\d{2})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches)) |
||
| 27 | return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5]; |
||
| 28 | |||
| 29 | return $phone; |
||
| 41 | } |