Completed
Pull Request — master (#24)
by Andres
03:07
created
src/Validator/AbstractValidator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             } while (next($this->validationStack));
81 81
 
82 82
             return $value;
83
-        } catch (ValidationException $validationException) {
83
+        }catch (ValidationException $validationException) {
84 84
             if ($this->toBool) {
85 85
                 return false;
86 86
             }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     {
104 104
         $this->optional = false;
105 105
 
106
-        $this->add(function ($value, $nameKey) {
106
+        $this->add(function($value, $nameKey) {
107 107
             if (is_null($value)) {
108 108
                 $this->createError('required', $value, $nameKey);
109 109
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function anyOf(array $vals)
149 149
     {
150
-        $this->add(function ($value, $nameKey) use ($vals) {
150
+        $this->add(function($value, $nameKey) use ($vals) {
151 151
             if (!in_array($value, $vals)) {
152 152
                 return $this->createError('anyof', $value, $nameKey);
153 153
             }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      */
191 191
     public function alternatives($conditions)
192 192
     {
193
-        $this->add(function ($value, $nameKey) use ($conditions) {
193
+        $this->add(function($value, $nameKey) use ($conditions) {
194 194
 
195 195
             foreach ($conditions as $condition) {
196 196
                 if (!isset($condition['is'])) {
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      */
243 243
     public function errorMessages(array $errorMessages)
244 244
     {
245
-        $errorMessages = array_map(function ($errorMessage) {
245
+        $errorMessages = array_map(function($errorMessage) {
246 246
             if (is_string($errorMessage)) {
247 247
                 $errorMessage = ['message' => $errorMessage];
248 248
             }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
         $errorHandler = $this->errorHandlers[$key];
277 277
         if (!array_key_exists('message_formatter', $errorHandler)) {
278
-            $messageFormatter = function ($template, $value, $validationValue = null) {
278
+            $messageFormatter = function($template, $value, $validationValue = null) {
279 279
                 return sprintf($template, $value, $validationValue);
280 280
             };
281 281
         } else {
Please login to merge, or discard this patch.
src/Validator/ArrayValidator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
         $this->toBool(false);
19 19
 
20
-        $this->add(function ($value, $nameKey) {
20
+        $this->add(function($value, $nameKey) {
21 21
             if (!is_array($value)) {
22 22
                 return $this->createError('array.not_array', $value, $nameKey);
23 23
             }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function keys(array $definition)
55 55
     {
56
-        return $this->add(function (&$value) use ($definition) {
56
+        return $this->add(function(&$value) use ($definition) {
57 57
             /**
58 58
              * @var string $key
59 59
              * @var AbstractValidator $validator
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function min($min)
89 89
     {
90
-        return $this->add(function ($value, $nameKey) use ($min) {
90
+        return $this->add(function($value, $nameKey) use ($min) {
91 91
             if (count($value) < $min) {
92 92
                 return $this->createError('array.min', $value, $nameKey);
93 93
             }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function max($max)
104 104
     {
105
-        return $this->add(function ($value, $nameKey) use ($max) {
105
+        return $this->add(function($value, $nameKey) use ($max) {
106 106
             if (count($value) > $max) {
107 107
                 return $this->createError('array.max', $value, $nameKey);
108 108
             }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function length($length)
119 119
     {
120
-        return $this->add(function ($value, $nameKey) use ($length) {
120
+        return $this->add(function($value, $nameKey) use ($length) {
121 121
             if (count($value) != $length) {
122 122
                 return $this->createError('array.length', $value, $nameKey);
123 123
             }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function unique()
133 133
     {
134
-        return $this->add(function ($value, $nameKey) {
134
+        return $this->add(function($value, $nameKey) {
135 135
             if (md5(serialize($value)) != md5(serialize(array_unique($value)))) {
136 136
                 return $this->createError('array.unique', $value, $nameKey);
137 137
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function items(AbstractValidator $definition)
149 149
     {
150
-        return $this->add(function ($value, $nameKey) use ($definition) {
150
+        return $this->add(function($value, $nameKey) use ($definition) {
151 151
             foreach ($value as $key => $val) {
152 152
                 $resp = $definition($val, $nameKey);
153 153
                 if ($resp instanceof ValidationError) {
Please login to merge, or discard this patch.
src/Validator/DateValidator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function format($format)
13 13
     {
14
-        return $this->add(function ($value, $namekey) use ($format) {
14
+        return $this->add(function($value, $namekey) use ($format) {
15 15
             $date = \DateTime::createFromFormat($format, $value);
16 16
             if (false === $date) {
17 17
                 return $this->createError('date.format', $value, $namekey);
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function min($date)
29 29
     {
30
-        return $this->add(function ($value, $nameKey) use ($date) {
30
+        return $this->add(function($value, $nameKey) use ($date) {
31 31
             $minDate = strtotime($date);
32 32
             $curDate = strtotime($value);
33 33
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function max($date)
47 47
     {
48
-        return $this->add(function ($value, $nameKey) use ($date) {
48
+        return $this->add(function($value, $nameKey) use ($date) {
49 49
             $maxDate = strtotime($date);
50 50
             $curDate = strtotime($value);
51 51
 
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function timestamp()
64 64
     {
65
-        return $this->add(function ($value, $nameKey) {
65
+        return $this->add(function($value, $nameKey) {
66 66
             try {
67 67
                 new \DateTime('@' . $value);
68
-            } catch (\Exception $e) {
68
+            }catch (\Exception $e) {
69 69
                 return $this->createError('date.timestamp', $value, $nameKey);
70 70
             }
71 71
         });
Please login to merge, or discard this patch.
src/Validator/StringValidator.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             ]
43 43
         ];
44 44
 
45
-        $this->add(function ($value, $nameKey) {
45
+        $this->add(function($value, $nameKey) {
46 46
             if (is_null($value)) {
47 47
                 return;
48 48
             }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function token()
63 63
     {
64
-        return $this->add(function ($value, $nameKey) {
64
+        return $this->add(function($value, $nameKey) {
65 65
             preg_match('/[a-zA-Z0-9_]+/', $value, $matches);
66 66
             if (!(isset($matches[0]) && ($matches[0] == $value))) {
67 67
                 $this->createError('string.token', $value, $nameKey);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function min($min)
80 80
     {
81
-        return $this->add(function ($value, $nameKey) use ($min) {
81
+        return $this->add(function($value, $nameKey) use ($min) {
82 82
             if (strlen($value) < $min) {
83 83
                 $this->createError('string.min', $value, $nameKey, $min);
84 84
             }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function max($max)
95 95
     {
96
-        return $this->add(function ($value, $nameKey) use ($max) {
96
+        return $this->add(function($value, $nameKey) use ($max) {
97 97
             if (strlen($value) > $max) {
98 98
                 return $this->createError('string.max', $value, $nameKey, $max);
99 99
             }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function matches($regex)
110 110
     {
111
-        return $this->add(function ($value, $nameKey) use ($regex) {
111
+        return $this->add(function($value, $nameKey) use ($regex) {
112 112
             if (!preg_match($regex, $value)) {
113 113
                 return $this->createError('string.matches', $value, $nameKey, $regex);
114 114
             }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function length($length)
124 124
     {
125
-        return $this->add(function ($value, $nameKey) use ($length) {
125
+        return $this->add(function($value, $nameKey) use ($length) {
126 126
             if (strlen($value) != $length) {
127 127
                 return $this->createError('string.length', $value, $nameKey, $length);
128 128
             }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function alphanum()
138 138
     {
139
-        return $this->add(function ($value, $nameKey) {
139
+        return $this->add(function($value, $nameKey) {
140 140
             if (!ctype_alnum($value)) {
141 141
                 return $this->createError('string.alphanum', $value, $nameKey);
142 142
             }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function alpha()
152 152
     {
153
-        return $this->add(function ($value, $nameKey) {
153
+        return $this->add(function($value, $nameKey) {
154 154
             if (!ctype_alpha($value)) {
155 155
                 return $this->createError('string.alpha', $value, $nameKey);
156 156
             }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function email()
166 166
     {
167
-        return $this->add(function ($value, $nameKey) {
167
+        return $this->add(function($value, $nameKey) {
168 168
             if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
169 169
                 return $this->createError('string.email', $value, $nameKey);
170 170
             }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function ip()
180 180
     {
181
-        return $this->add(function ($value, $nameKey) {
181
+        return $this->add(function($value, $nameKey) {
182 182
             if (!filter_var($value, FILTER_VALIDATE_IP)) {
183 183
                 return $this->createError('string.ip', $value, $nameKey);
184 184
             }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public function uri()
194 194
     {
195
-        return $this->add(function ($value, $nameKey) {
195
+        return $this->add(function($value, $nameKey) {
196 196
             if (!filter_var($value, FILTER_VALIDATE_URL)) {
197 197
                 return $this->createError('string.uri', $value, $nameKey);
198 198
             }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function replace($pattern, $replacement)
211 211
     {
212
-        return $this->add(function ($value, $nameKey) use ($pattern, $replacement) {
212
+        return $this->add(function($value, $nameKey) use ($pattern, $replacement) {
213 213
             return preg_replace($pattern, $replacement, $value);
214 214
         });
215 215
     }
Please login to merge, or discard this patch.
src/Validator/NumberValidator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function min($min)
43 43
     {
44
-        return $this->add(function ($value, $nameKey) use ($min) {
44
+        return $this->add(function($value, $nameKey) use ($min) {
45 45
             if ($value < $min) {
46 46
                 return $this->createError('number.min', $value, $nameKey);
47 47
             }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function max($max)
58 58
     {
59
-        return $this->add(function ($value, $nameKey) use ($max) {
59
+        return $this->add(function($value, $nameKey) use ($max) {
60 60
             if ($value > $max) {
61 61
                 return $this->createError('number.max', $value, $nameKey);
62 62
             }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function precision($precision)
74 74
     {
75
-        return $this->add(function ($value, $nameKey) use ($precision) {
75
+        return $this->add(function($value, $nameKey) use ($precision) {
76 76
             if (strlen(substr($value, strpos($value, '.') + 1)) != $precision) {
77 77
                 return $this->createError('number.precision', $value, $nameKey);
78 78
             }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function isInt()
88 88
     {
89
-        return $this->add(function ($value, $nameKey) {
89
+        return $this->add(function($value, $nameKey) {
90 90
             if (!is_int($value)) {
91 91
                 return $this->createError('number.is_int', $value, $nameKey);
92 92
             }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function isFloat()
102 102
     {
103
-        return $this->add(function ($value, $nameKey) {
103
+        return $this->add(function($value, $nameKey) {
104 104
             if (!is_float($value)) {
105 105
                 return $this->createError('number.is_float', $value, $nameKey);
106 106
             }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function isNumber()
116 116
     {
117
-        return $this->add(function ($value, $nameKey) {
117
+        return $this->add(function($value, $nameKey) {
118 118
             if (!is_numeric($value)) {
119 119
                 return $this->createError('number.is_numeric', $value, $nameKey);
120 120
             }
Please login to merge, or discard this patch.
src/Validator/JsonValidator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
         $this->toBool(false);
18 18
 
19
-        $this->add(function ($value, $nameKey) {
19
+        $this->add(function($value, $nameKey) {
20 20
             json_decode($value);
21 21
             if (json_last_error() != JSON_ERROR_NONE) {
22 22
                 return $this->createError('json.invalid', $value, $nameKey);
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function keys(array $definition)
34 34
     {
35
-        return $this->add(function ($value, $nameKey) use ($definition) {
35
+        return $this->add(function($value, $nameKey) use ($definition) {
36 36
             $decodedValue = json_decode($value, true);
37 37
             $validation = $this->array()->keys($definition);
38 38
             return $validation($decodedValue);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function items(AbstractValidator $definition)
49 49
     {
50
-        return $this->add(function ($value, $nameKey) use ($definition) {
50
+        return $this->add(function($value, $nameKey) use ($definition) {
51 51
             $decodedValue = json_decode($value, true);
52 52
             $validation = $this->array()->items($definition);
53 53
             return $validation($decodedValue);
Please login to merge, or discard this patch.