Passed
Push — master ( 470ad5...955b74 )
by Dedipyaman
02:14
created
src/Rule/String/MaximumLength.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,14 +22,16 @@
 block discarded – undo
22 22
     {
23 23
         $result = (new StringType())->validate($data);
24 24
 
25
-        if (!$result->isValid())
26
-            return new $result;
25
+        if (!$result->isValid()) {
26
+                    return new $result;
27
+        }
27 28
 
28 29
         if (mb_strlen($data, 'UTF-8') <= $this->maxLength) {
29 30
             return new Success();
30
-        }
31
-        else return new Failure(
31
+        } else {
32
+            return new Failure(
32 33
             new RuleError(RuleErrorCode::LENGTH_ERROR,
33 34
                 'The supplied string is too long'));
35
+        }
34 36
     }
35 37
 }
36 38
\ No newline at end of file
Please login to merge, or discard this patch.
src/Rule/String/MinimumLength.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,14 +20,16 @@
 block discarded – undo
20 20
     {
21 21
         $result = (new StringType())->validate($data);
22 22
 
23
-        if (!$result->isValid())
24
-            return new $result;
23
+        if (!$result->isValid()) {
24
+                    return new $result;
25
+        }
25 26
 
26 27
         if (mb_strlen($data, 'UTF-8') >= $this->minLength) {
27 28
             return new Result\Success();
28
-        }
29
-        else return new Result\Failure(
29
+        } else {
30
+            return new Result\Failure(
30 31
             new RuleError(RuleErrorCode::LENGTH_ERROR,
31 32
             'The supplied string is too short'));
33
+        }
32 34
     }
33 35
 }
34 36
\ No newline at end of file
Please login to merge, or discard this patch.
src/Rule/String/TextCase.php 1 patch
Braces   +36 added lines, -28 removed lines patch added patch discarded remove patch
@@ -47,8 +47,9 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function __construct(int $caseType, bool $allowSpecialChars = true)
49 49
     {
50
-        if ($caseType > 4 || $caseType < 0)
51
-            throw new InvalidRuleOption($caseType, TextCase::class);
50
+        if ($caseType > 4 || $caseType < 0) {
51
+                    throw new InvalidRuleOption($caseType, TextCase::class);
52
+        }
52 53
 
53 54
         $this->caseType = $caseType;
54 55
         $this->strictCheck = !$allowSpecialChars;
@@ -61,10 +62,11 @@  discard block
 block discarded – undo
61 62
     private function isMixed(string $text) : bool
62 63
     {
63 64
         if ($this->strictCheck) {
64
-            if (preg_match("/^[a-zA-Z]+$/", $text))
65
-                return preg_match('/[a-z]/', $text) && preg_match('/[A-Z]/', $text);
66
-            else
67
-                return false;
65
+            if (preg_match("/^[a-zA-Z]+$/", $text)) {
66
+                            return preg_match('/[a-z]/', $text) && preg_match('/[A-Z]/', $text);
67
+            } else {
68
+                            return false;
69
+            }
68 70
         }
69 71
 
70 72
         return preg_match('/[a-z]/', $text) && preg_match('/[A-Z]/', $text);
@@ -72,47 +74,52 @@  discard block
 block discarded – undo
72 74
 
73 75
     private function isAllUpper(string $text) : bool
74 76
     {
75
-        if ($this->strictCheck)
76
-            return ctype_upper($text);
77
-        else
78
-            return !preg_match('/[a-z]/', $text) && preg_match('/[A-Z]/', $text);
77
+        if ($this->strictCheck) {
78
+                    return ctype_upper($text);
79
+        } else {
80
+                    return !preg_match('/[a-z]/', $text) && preg_match('/[A-Z]/', $text);
81
+        }
79 82
             
80 83
     }
81 84
 
82 85
     private function isAllLower(string $text) : bool
83 86
     {
84
-        if ($this->strictCheck)
85
-            return ctype_lower($text);
86
-        else
87
-            return preg_match('/[a-z]/', $text) && !preg_match('/[A-Z]/', $text);
87
+        if ($this->strictCheck) {
88
+                    return ctype_lower($text);
89
+        } else {
90
+                    return preg_match('/[a-z]/', $text) && !preg_match('/[A-Z]/', $text);
91
+        }
88 92
     }
89 93
 
90 94
     private function isSomeLower(string $text) : bool
91 95
     {
92 96
         $containsLower = (bool) preg_match('/[a-z]/', $text);
93 97
 
94
-        if ($this->strictCheck)
95
-           return !preg_match('/[\W]/', $text) && $containsLower;
96
-        else
97
-            return $containsLower;
98
+        if ($this->strictCheck) {
99
+                   return !preg_match('/[\W]/', $text) && $containsLower;
100
+        } else {
101
+                    return $containsLower;
102
+        }
98 103
     }
99 104
 
100 105
     private function isSomeUpper(string $text) : bool
101 106
     {
102 107
         $containsUpper = (bool) preg_match('/[A-Z]/', $text);
103 108
 
104
-        if ($this->strictCheck)
105
-            return !preg_match('/[\W]/', $text) && $containsUpper;
106
-        else
107
-            return $containsUpper;
109
+        if ($this->strictCheck) {
110
+                    return !preg_match('/[\W]/', $text) && $containsUpper;
111
+        } else {
112
+                    return $containsUpper;
113
+        }
108 114
     }
109 115
 
110 116
     public function validate($data): Result
111 117
     {
112 118
         $result = (new StringType())->validate($data);
113 119
 
114
-        if (!$result->isValid())
115
-            return new $result;
120
+        if (!$result->isValid()) {
121
+                    return new $result;
122
+        }
116 123
 
117 124
         $isValid = false;
118 125
 
@@ -134,10 +141,11 @@  discard block
 block discarded – undo
134 141
                 break;
135 142
         }
136 143
 
137
-        if ($isValid)
138
-            return new Success();
139
-        else
140
-            return new Failure(new RuleError(RuleErrorCode::CASING_MISMATCH,
144
+        if ($isValid) {
145
+                    return new Success();
146
+        } else {
147
+                    return new Failure(new RuleError(RuleErrorCode::CASING_MISMATCH,
141 148
                 "The given string doesn't match the required case"));
149
+        }
142 150
     }
143 151
 }
144 152
\ No newline at end of file
Please login to merge, or discard this patch.
src/Rule/String/ExactLength.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,14 +35,16 @@
 block discarded – undo
35 35
     {
36 36
         $result = (new StringType())->validate($data);
37 37
 
38
-        if (!$result->isValid())
39
-            return new $result;
38
+        if (!$result->isValid()) {
39
+                    return new $result;
40
+        }
40 41
 
41 42
         if (mb_strlen($data, 'UTF-8') == $this->length) {
42 43
             return new Success();
43
-        }
44
-        else return new Failure(
44
+        } else {
45
+            return new Failure(
45 46
             new RuleError(RuleErrorCode::LENGTH_ERROR,
46 47
                 'The supplied string is not of correct length'));
48
+        }
47 49
     }
48 50
 }
49 51
\ No newline at end of file
Please login to merge, or discard this patch.