Passed
Push — master ( 3db3b7...c2e9f1 )
by Dedipyaman
02:09
created
src/Rule/Pattern/ContainsKeyword.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,9 +33,10 @@
 block discarded – undo
33 33
 
34 34
     public function validate($data): Result
35 35
     {
36
-        if (strpos($data, $this->keyword) !== false)
37
-            return new Success();
38
-        else
39
-            return new Failure(new RuleError(RuleErrorCode::PATTERN_MISMATCH, "String does not contain keyword"));
36
+        if (strpos($data, $this->keyword) !== false) {
37
+                    return new Success();
38
+        } else {
39
+                    return new Failure(new RuleError(RuleErrorCode::PATTERN_MISMATCH, "String does not contain keyword"));
40
+        }
40 41
     }
41 42
 }
42 43
\ No newline at end of file
Please login to merge, or discard this patch.
src/Type/Password.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      * @throws \Phypes\Exception\InvalidAggregateRule
25 25
      * @throws \Phypes\Exception\InvalidRuleOption
26 26
      */
27
-    public function __construct(string $password, $options =[], Validator $validator = null)
27
+    public function __construct(string $password, $options = [ ], Validator $validator = null)
28 28
     {
29 29
         if ($validator == null) {
30 30
             // use the default validator
Please login to merge, or discard this patch.
src/Type/Username.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@
 block discarded – undo
28 28
     private $username;
29 29
 
30 30
 
31
-    public function __construct(string $username, $options = [], Validator $validator = null)
31
+    public function __construct(string $username, $options = [ ], Validator $validator = null)
32 32
     {
33 33
         if ($validator == null) {
34 34
             // use the default validator
35 35
             $validator = new UsernameValidator(
36 36
                 getOptionalValue(self::OPT_MIN_LEN, $options, 4),
37 37
                 getOptionalValue(self::OPT_MAX_LEN, $options, 12),
38
-                getOptionalValue(self::OPT_ALLOWED_SPECIAL_CHARS, $options, ['-', '_']));
38
+                getOptionalValue(self::OPT_ALLOWED_SPECIAL_CHARS, $options, [ '-', '_' ]));
39 39
         }
40 40
 
41 41
         $result = $validator->validate($username, $options);
Please login to merge, or discard this patch.
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   +33 added lines, -26 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function __construct(int $caseType, bool $allowSpecialChars = true)
48 48
     {
49
-        if ($caseType > 4 || $caseType < 0)
50
-            throw new InvalidRuleOption($caseType);
49
+        if ($caseType > 4 || $caseType < 0) {
50
+                    throw new InvalidRuleOption($caseType);
51
+        }
51 52
 
52 53
         $this->caseType = $caseType;
53 54
         $this->strictCheck = !$allowSpecialChars;
@@ -60,10 +61,11 @@  discard block
 block discarded – undo
60 61
     private function isMixed(string $text) : bool
61 62
     {
62 63
         if ($this->strictCheck) {
63
-            if (preg_match("/^[a-zA-Z]+$/", $text))
64
-                return preg_match('/[a-z]/', $text) && preg_match('/[A-Z]/', $text);
65
-            else
66
-                return false;
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;
68
+            }
67 69
         }
68 70
 
69 71
         return preg_match('/[a-z]/', $text) && preg_match('/[A-Z]/', $text);
@@ -71,39 +73,43 @@  discard block
 block discarded – undo
71 73
 
72 74
     private function isAllUpper(string $text) : bool
73 75
     {
74
-        if ($this->strictCheck)
75
-            return ctype_upper($text);
76
-        else
77
-            return !preg_match('/[a-z]/', $text) && preg_match('/[A-Z]/', $text);
76
+        if ($this->strictCheck) {
77
+                    return ctype_upper($text);
78
+        } else {
79
+                    return !preg_match('/[a-z]/', $text) && preg_match('/[A-Z]/', $text);
80
+        }
78 81
             
79 82
     }
80 83
 
81 84
     private function isAllLower(string $text) : bool
82 85
     {
83
-        if ($this->strictCheck)
84
-            return ctype_lower($text);
85
-        else
86
-            return preg_match('/[a-z]/', $text) && !preg_match('/[A-Z]/', $text);
86
+        if ($this->strictCheck) {
87
+                    return ctype_lower($text);
88
+        } else {
89
+                    return preg_match('/[a-z]/', $text) && !preg_match('/[A-Z]/', $text);
90
+        }
87 91
     }
88 92
 
89 93
     private function isSomeLower(string $text) : bool
90 94
     {
91 95
         $containsLower = (bool) preg_match('/[a-z]/', $text);
92 96
 
93
-        if ($this->strictCheck)
94
-           return !preg_match('/[\W]/', $text) && $containsLower;
95
-        else
96
-            return $containsLower;
97
+        if ($this->strictCheck) {
98
+                   return !preg_match('/[\W]/', $text) && $containsLower;
99
+        } else {
100
+                    return $containsLower;
101
+        }
97 102
     }
98 103
 
99 104
     private function isSomeUpper(string $text) : bool
100 105
     {
101 106
         $containsUpper = (bool) preg_match('/[A-Z]/', $text);
102 107
 
103
-        if ($this->strictCheck)
104
-            return !preg_match('/[\W]/', $text) && $containsUpper;
105
-        else
106
-            return $containsUpper;
108
+        if ($this->strictCheck) {
109
+                    return !preg_match('/[\W]/', $text) && $containsUpper;
110
+        } else {
111
+                    return $containsUpper;
112
+        }
107 113
     }
108 114
 
109 115
     public function validate($data): Result
@@ -128,10 +134,11 @@  discard block
 block discarded – undo
128 134
                 break;
129 135
         }
130 136
 
131
-        if ($isValid)
132
-            return new Success();
133
-        else
134
-            return new Failure(new RuleError(RuleErrorCode::CASING_MISMATCH,
137
+        if ($isValid) {
138
+                    return new Success();
139
+        } else {
140
+                    return new Failure(new RuleError(RuleErrorCode::CASING_MISMATCH,
135 141
                 "The given string doesn't match the required case"));
142
+        }
136 143
     }
137 144
 }
138 145
\ No newline at end of file
Please login to merge, or discard this patch.
src/Rule/String/MaximumLength.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,9 +21,10 @@
 block discarded – undo
21 21
     {
22 22
         if (mb_strlen($data, 'UTF-8') <= $this->maxLength) {
23 23
             return new Success();
24
-        }
25
-        else return new Failure(
24
+        } else {
25
+            return new Failure(
26 26
             new RuleError(RuleErrorCode::LENGTH_ERROR,
27 27
                 'The supplied string is too long'));
28
+        }
28 29
     }
29 30
 }
30 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/Rule/String/MinimumLength.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,9 +20,10 @@
 block discarded – undo
20 20
     {
21 21
         if (mb_strlen($data, 'UTF-8') >= $this->minLength) {
22 22
             return new Result\Success();
23
-        }
24
-        else return new Result\Failure(
23
+        } else {
24
+            return new Result\Failure(
25 25
             new RuleError(RuleErrorCode::LENGTH_ERROR,
26 26
             'The supplied string is too short'));
27
+        }
27 28
     }
28 29
 }
29 30
\ 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/Rule/String/ExactLength.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,9 +34,10 @@
 block discarded – undo
34 34
     {
35 35
         if (mb_strlen($data, 'UTF-8') == $this->length) {
36 36
             return new Success();
37
-        }
38
-        else return new Failure(
37
+        } else {
38
+            return new Failure(
39 39
             new RuleError(RuleErrorCode::LENGTH_ERROR,
40 40
                 'The supplied string is not of correct length'));
41
+        }
41 42
     }
42 43
 }
43 44
\ No newline at end of file
Please login to merge, or discard this patch.