Passed
Push — master ( 6c8253...8e7622 )
by Dedipyaman
02:03 queued 10s
created
src/helpers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,5 +17,5 @@
 block discarded – undo
17 17
  * @return mixed
18 18
  */
19 19
 function getOptionalValue(int $key, array $arr, $default) {
20
-    return isset($arr[$key]) ? $arr[$key]: $default;
20
+    return isset($arr[ $key ]) ? $arr[ $key ] : $default;
21 21
 }
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
src/Rule/String/TextCase.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
         $containsLower = (bool) preg_match('/[a-z]/', $text);
92 92
 
93 93
         if ($this->strictCheck)
94
-           return !preg_match('/[\W]/', $text) && $containsLower;
94
+            return !preg_match('/[\W]/', $text) && $containsLower;
95 95
         else
96 96
             return $containsLower;
97 97
     }
Please login to merge, or discard this 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/Validator/NameValidator.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     /**
36 36
      * @var array $allowedChars
37 37
      */
38
-    private $allowedChars = [];
38
+    private $allowedChars = [ ];
39 39
 
40 40
     /**
41 41
      * NameValidator constructor.
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param int $maxLength
45 45
      * @param array $allowedChars
46 46
      */
47
-    public function __construct(int $minLength = 1, int $maxLength = 255, $allowedChars = ["\'", "-", ".", " "])
47
+    public function __construct(int $minLength = 1, int $maxLength = 255, $allowedChars = [ "\'", "-", ".", " " ])
48 48
     {
49 49
         $this->minLength = $minLength;
50 50
         $this->maxLength = $maxLength;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,8 +66,9 @@
 block discarded – undo
66 66
 
67 67
         $result = $rule->validate($name);
68 68
 
69
-        if ($result->isValid())
70
-            return new Success();
69
+        if ($result->isValid()) {
70
+                    return new Success();
71
+        }
71 72
         /**
72 73
          * @var Failure $result
73 74
          */
Please login to merge, or discard this patch.
src/Exception/InvalidValue.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
      * @param array|Error $errors
27 27
      * @param int $code
28 28
      */
29
-    public function __construct(string $message = "", $errors = [], int $code = 0)
29
+    public function __construct(string $message = "", $errors = [ ], int $code = 0)
30 30
     {
31 31
         parent::__construct($message, $code);
32 32
         $this->errors = $errors;
Please login to merge, or discard this patch.
src/Rule/Number/Equals.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,11 +36,13 @@
 block discarded – undo
36 36
     {
37 37
         $numericResult = (new NumericType())->validate($value);
38 38
 
39
-        if (!$numericResult->isValid())
40
-            return new $numericResult;
39
+        if (!$numericResult->isValid()) {
40
+                    return new $numericResult;
41
+        }
41 42
 
42
-        if ($value == $this->expected)
43
-            return new Success();
43
+        if ($value == $this->expected) {
44
+                    return new Success();
45
+        }
44 46
 
45 47
         return new Failure(new RuleError(RuleErrorCode::LESS_THAN_MINIMUM,
46 48
             'The supplied number is less than the expectedimum value'));
Please login to merge, or discard this patch.
src/Rule/Number/Minimum.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,11 +36,13 @@
 block discarded – undo
36 36
     {
37 37
         $numericResult = (new NumericType())->validate($value);
38 38
 
39
-        if (!$numericResult->isValid())
40
-            return new $numericResult;
39
+        if (!$numericResult->isValid()) {
40
+                    return new $numericResult;
41
+        }
41 42
 
42
-        if ($value >= $this->min)
43
-            return new Success();
43
+        if ($value >= $this->min) {
44
+                    return new Success();
45
+        }
44 46
 
45 47
         return new Failure(new RuleError(RuleErrorCode::LESS_THAN_MINIMUM,
46 48
             'The supplied number is less than the minimum value'));
Please login to merge, or discard this patch.
src/Rule/Number/Negative.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,11 +27,13 @@
 block discarded – undo
27 27
     {
28 28
         $numericResult = (new NumericType())->validate($value);
29 29
 
30
-        if (!$numericResult->isValid())
31
-            return new $numericResult;
30
+        if (!$numericResult->isValid()) {
31
+                    return new $numericResult;
32
+        }
32 33
 
33
-        if ($value < 0)
34
-            return new Success();
34
+        if ($value < 0) {
35
+                    return new Success();
36
+        }
35 37
 
36 38
         return new Failure(new RuleError(RuleErrorCode::NOT_NEGATIVE, 'The supplied number is not negative'));
37 39
     }
Please login to merge, or discard this patch.
src/Rule/Number/Maximum.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,11 +36,13 @@
 block discarded – undo
36 36
     {
37 37
         $numericResult = (new NumericType())->validate($value);
38 38
 
39
-        if (!$numericResult->isValid())
40
-            return new $numericResult;
39
+        if (!$numericResult->isValid()) {
40
+                    return new $numericResult;
41
+        }
41 42
 
42
-        if ($value <= $this->max)
43
-            return new Success();
43
+        if ($value <= $this->max) {
44
+                    return new Success();
45
+        }
44 46
 
45 47
         return new Failure(new RuleError(RuleErrorCode::EXCEEDS_MAXIMUM, 'The supplied number exceeds the maximum value'));
46 48
     }
Please login to merge, or discard this patch.
src/Rule/Number/Positive.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,11 +27,13 @@
 block discarded – undo
27 27
     {
28 28
         $numericResult = (new NumericType())->validate($value);
29 29
 
30
-        if (!$numericResult->isValid())
31
-            return new $numericResult;
30
+        if (!$numericResult->isValid()) {
31
+                    return new $numericResult;
32
+        }
32 33
 
33
-        if ($value > 0)
34
-            return new Success();
34
+        if ($value > 0) {
35
+                    return new Success();
36
+        }
35 37
 
36 38
         return new Failure(new RuleError(RuleErrorCode::NOT_POSITIVE, 'The supplied number is not positive'));
37 39
     }
Please login to merge, or discard this patch.