@@ -21,8 +21,7 @@ discard block |
||
21 | 21 | public function __construct(?callable $errorFormatter = null) |
22 | 22 | { |
23 | 23 | $this->errorFormatter = is_callable($errorFormatter) ? |
24 | - $errorFormatter : |
|
25 | - function ($data) { |
|
24 | + $errorFormatter : function($data) { |
|
26 | 25 | return [self::NOT_A_FLOAT]; |
27 | 26 | }; |
28 | 27 | } |
@@ -34,7 +33,7 @@ discard block |
||
34 | 33 | |
35 | 34 | public function validate($data, array $context = []): ValidationResult |
36 | 35 | { |
37 | - if (! is_float($data)) { |
|
36 | + if (!is_float($data)) { |
|
38 | 37 | return ValidationResult::errors(($this->errorFormatter)($data)); |
39 | 38 | } |
40 | 39 |
@@ -27,8 +27,7 @@ |
||
27 | 27 | { |
28 | 28 | $this->pattern = $pattern; |
29 | 29 | $this->errorFormatter = is_callable($errorFormatter) ? |
30 | - $errorFormatter : |
|
31 | - function (string $key, $data) { |
|
30 | + $errorFormatter : function(string $key, $data) { |
|
32 | 31 | return [self::MATCH_FAILED]; |
33 | 32 | }; |
34 | 33 | } |
@@ -20,8 +20,7 @@ |
||
20 | 20 | public function __construct(?callable $errorFormatter = null) |
21 | 21 | { |
22 | 22 | $this->errorFormatter = is_callable($errorFormatter) ? |
23 | - $errorFormatter : |
|
24 | - function ($data) { |
|
23 | + $errorFormatter : function($data) { |
|
25 | 24 | return [self::NOT_NULL]; |
26 | 25 | }; |
27 | 26 | } |
@@ -27,8 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $this->key = $key; |
29 | 29 | $this->errorFormatter = is_callable($errorFormatter) ? |
30 | - $errorFormatter : |
|
31 | - function (string $key, $data) { |
|
30 | + $errorFormatter : function(string $key, $data) { |
|
32 | 31 | return [self::MISSING_KEY]; |
33 | 32 | }; |
34 | 33 | } |
@@ -45,7 +44,7 @@ discard block |
||
45 | 44 | |
46 | 45 | public function validate($data, array $context = []): ValidationResult |
47 | 46 | { |
48 | - if (! array_key_exists($this->key, $data)) { |
|
47 | + if (!array_key_exists($this->key, $data)) { |
|
49 | 48 | return ValidationResult::errors(($this->errorFormatter)($this->key, $data)); |
50 | 49 | } |
51 | 50 |
@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | { |
27 | 27 | $this->className = $className; |
28 | 28 | $this->errorFormatter = is_callable($errorFormatter) ? |
29 | - $errorFormatter : |
|
30 | - function (string $className, $data) { |
|
29 | + $errorFormatter : function(string $className, $data) { |
|
31 | 30 | return [self::NOT_AN_INSTANCE]; |
32 | 31 | }; |
33 | 32 | } |
@@ -44,7 +43,7 @@ discard block |
||
44 | 43 | |
45 | 44 | public function validate($data, array $context = []): ValidationResult |
46 | 45 | { |
47 | - if (! $data instanceof $this->className) { |
|
46 | + if (!$data instanceof $this->className) { |
|
48 | 47 | return ValidationResult::errors(($this->errorFormatter)($this->className, $data)); |
49 | 48 | } |
50 | 49 |
@@ -20,8 +20,7 @@ |
||
20 | 20 | public function __construct(?callable $errorFormatter = null) |
21 | 21 | { |
22 | 22 | $this->errorFormatter = is_callable($errorFormatter) ? |
23 | - $errorFormatter : |
|
24 | - function ($data) { |
|
23 | + $errorFormatter : function($data) { |
|
25 | 24 | return [self::NOT_NOT_NULL]; |
26 | 25 | }; |
27 | 26 | } |
@@ -33,8 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | $this->validations = $validations; |
35 | 35 | $this->errorFormatter = is_callable($errorFormatter) ? |
36 | - $errorFormatter : |
|
37 | - 'array_merge'; |
|
36 | + $errorFormatter : 'array_merge'; |
|
38 | 37 | } |
39 | 38 | |
40 | 39 | /** |
@@ -65,7 +64,7 @@ discard block |
||
65 | 64 | foreach ($this->validations as $validation) { |
66 | 65 | $result = $result->join( |
67 | 66 | $validation->validate($data, $context), |
68 | - function ($a, $b) { |
|
67 | + function($a, $b) { |
|
69 | 68 | return $a; |
70 | 69 | }, |
71 | 70 | $this->errorFormatter |
@@ -33,8 +33,7 @@ |
||
33 | 33 | |
34 | 34 | $this->validations = $validations; |
35 | 35 | $this->errorFormatter = is_callable($errorFormatter) ? |
36 | - $errorFormatter : |
|
37 | - function (array $messages) { |
|
36 | + $errorFormatter : function(array $messages) { |
|
38 | 37 | return [ |
39 | 38 | self::NOT_EVEN_ONE => $messages |
40 | 39 | ]; |
@@ -42,12 +42,12 @@ |
||
42 | 42 | { |
43 | 43 | return array_reduce( |
44 | 44 | $this->validations, |
45 | - function (ValidationResult $carry, Validation $validation) use ($context) { |
|
45 | + function(ValidationResult $carry, Validation $validation) use ($context) { |
|
46 | 46 | return $carry->process( |
47 | - function ($validData) use ($validation, $context) { |
|
47 | + function($validData) use ($validation, $context) { |
|
48 | 48 | return $validation->validate($validData, $context); |
49 | 49 | }, |
50 | - function () use ($carry) { |
|
50 | + function() use ($carry) { |
|
51 | 51 | return $carry; |
52 | 52 | } |
53 | 53 | ); |