@@ -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_AN_ITERABLE]; |
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_iterable($data)) { |
|
36 | + if (!is_iterable($data)) { |
|
38 | 37 | return ValidationResult::errors(($this->errorFormatter)($data)); |
39 | 38 | } |
40 | 39 |
@@ -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 | } |
@@ -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_AN_OBJECT]; |
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_object($data)) { |
|
36 | + if (!is_object($data)) { |
|
38 | 37 | return ValidationResult::errors(($this->errorFormatter)($data)); |
39 | 38 | } |
40 | 39 |
@@ -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 | ); |
@@ -24,8 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $this->elementValidation = $validation; |
26 | 26 | $this->errorFormatter = is_callable($errorFormatter) ? |
27 | - $errorFormatter : |
|
28 | - function ($key, $resultMessages, $validationMessages) { |
|
27 | + $errorFormatter : function($key, $resultMessages, $validationMessages) { |
|
29 | 28 | $resultMessages[$key] = $validationMessages; |
30 | 29 | |
31 | 30 | return $resultMessages; |
@@ -56,13 +55,13 @@ discard block |
||
56 | 55 | foreach ($data as $key => $element) { |
57 | 56 | $result = $result->meet( |
58 | 57 | $this->elementValidation->validate($data[$key], $context), |
59 | - function ($resultMessages, $validationMessages) use ($key, $errorFormatter) { |
|
58 | + function($resultMessages, $validationMessages) use ($key, $errorFormatter) { |
|
60 | 59 | return $errorFormatter($key, $resultMessages, $validationMessages); |
61 | 60 | } |
62 | 61 | ); |
63 | 62 | } |
64 | 63 | |
65 | - return $result->map(function () use ($data) { |
|
64 | + return $result->map(function() use ($data) { |
|
66 | 65 | return $data; |
67 | 66 | }); |
68 | 67 | } |
@@ -24,8 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $this->elementValidation = $validation; |
26 | 26 | $this->errorFormatter = is_callable($errorFormatter) ? |
27 | - $errorFormatter : |
|
28 | - function ($key, $resultMessages, $validationMessages) { |
|
27 | + $errorFormatter : function($key, $resultMessages, $validationMessages) { |
|
29 | 28 | $resultMessages[$key] = $validationMessages; |
30 | 29 | |
31 | 30 | return $resultMessages; |
@@ -56,10 +55,10 @@ discard block |
||
56 | 55 | foreach ($data as $key => $element) { |
57 | 56 | $result = $result->join( |
58 | 57 | $this->elementValidation->validate($data[$key], $context), |
59 | - function ($a, $b) { |
|
58 | + function($a, $b) { |
|
60 | 59 | return $a; |
61 | 60 | }, |
62 | - function ($resultMessages, $validationMessages) use ($key, $errorFormatter) { |
|
61 | + function($resultMessages, $validationMessages) use ($key, $errorFormatter) { |
|
63 | 62 | return $errorFormatter($key, $resultMessages, $validationMessages); |
64 | 63 | } |
65 | 64 | ); |