Passed
Push — scrutinzer ( 0c3ec4...6192f6 )
by Evgenii
10:34
created
Category
src/PhoneFormatter.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,11 +20,13 @@
 block discarded – undo
20 20
      */
21 21
     public static function format($phone)
22 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];
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
+        }
25 26
 
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];
27
+        if (preg_match('/^(\d{2})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches)) {
28
+                    return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5];
29
+        }
28 30
 
29 31
         return $phone;
30 32
     }
Please login to merge, or discard this patch.
src/PhoneValidator.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -66,14 +66,17 @@  discard block
 block discarded – undo
66 66
      */
67 67
     protected function validateValue($value)
68 68
     {
69
-        if (is_array($value) || is_object($value))
70
-            return [Yii::t('yii', '{attribute} is invalid.'), []];
69
+        if (is_array($value) || is_object($value)) {
70
+                    return [Yii::t('yii', '{attribute} is invalid.'), []];
71
+        }
71 72
 
72
-        if (!is_numeric($value))
73
-            return [$this->formatError, []];
73
+        if (!is_numeric($value)) {
74
+                    return [$this->formatError, []];
75
+        }
74 76
 
75
-        if ((strlen(strval($value)) > 15) || (strlen(strval($value)) < 11))
76
-            return [$this->lengthError, []];
77
+        if ((strlen(strval($value)) > 15) || (strlen(strval($value)) < 11)) {
78
+                    return [$this->lengthError, []];
79
+        }
77 80
     }
78 81
 
79 82
     /**
@@ -83,8 +86,9 @@  discard block
 block discarded – undo
83 86
      */
84 87
     public function validate($value, &$error = null)
85 88
     {
86
-        if (!is_null($value) && !is_string($value) && !is_numeric($value))
87
-            return false;
89
+        if (!is_null($value) && !is_string($value) && !is_numeric($value)) {
90
+                    return false;
91
+        }
88 92
         $value = $this->clear($value);
89 93
         $result = $this->validateValue($value);
90 94
         if (!empty($result)) {
Please login to merge, or discard this patch.