Passed
Push — master ( ba1f38...ba5da0 )
by Evgenii
10:40
created
src/PhoneFormatter.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,15 +34,18 @@
 block discarded – undo
34 34
     public static function format($phone, $countCodeLength = 1)
35 35
     {
36 36
 
37
-        if (preg_match('/^(\d{1})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches) && $countCodeLength == 1)
38
-            return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5];
37
+        if (preg_match('/^(\d{1})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches) && $countCodeLength == 1) {
38
+                    return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5];
39
+        }
39 40
 
40
-        if (preg_match('/^(\d{2})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches) && $countCodeLength == 1)
41
-            return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5];
41
+        if (preg_match('/^(\d{2})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches) && $countCodeLength == 1) {
42
+                    return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5];
43
+        }
42 44
 
43
-        if ($countCodeLength == 2)
44
-            if (preg_match('/^(\d{2})(\d{3})(\d{2})(\d{2})(\d{2})$/', $phone, $matches))
45
+        if ($countCodeLength == 2) {
46
+                    if (preg_match('/^(\d{2})(\d{3})(\d{2})(\d{2})(\d{2})$/', $phone, $matches))
45 47
                 return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5];
48
+        }
46 49
 
47 50
         return $phone;
48 51
     }
Please login to merge, or discard this patch.