@@ -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 |
@@ -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 | ); |
@@ -30,7 +30,6 @@ |
||
30 | 30 | public function translate(string $string): string |
31 | 31 | { |
32 | 32 | return array_key_exists($string, $this->dictionary) ? |
33 | - $this->dictionary[$string] : |
|
34 | - $string; |
|
33 | + $this->dictionary[$string] : $string; |
|
35 | 34 | } |
36 | 35 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | public function join(self $that, callable $joinValid, callable $joinErrors): self |
45 | 45 | { |
46 | - if (! $this->isValid || ! $that->isValid) { |
|
46 | + if (!$this->isValid || !$that->isValid) { |
|
47 | 47 | return self::errors($joinErrors($this->messages, $that->messages)); |
48 | 48 | } |
49 | 49 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | callable $processValid, |
73 | 73 | callable $processErrors |
74 | 74 | ) { |
75 | - if (! $this->isValid) { |
|
75 | + if (!$this->isValid) { |
|
76 | 76 | return $processErrors($this->messages); |
77 | 77 | } |
78 | 78 | |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | public function map(callable $map): self |
87 | 87 | { |
88 | 88 | return $this->process( |
89 | - function ($validContent) use ($map) { |
|
89 | + function($validContent) use ($map) { |
|
90 | 90 | return self::valid($map($validContent)); |
91 | 91 | }, |
92 | - function ($messages) { |
|
92 | + function($messages) { |
|
93 | 93 | return self::errors($messages); |
94 | 94 | } |
95 | 95 | ); |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | public function mapErrors(callable $map): self |
99 | 99 | { |
100 | 100 | return $this->process( |
101 | - function ($validContent) { |
|
101 | + function($validContent) { |
|
102 | 102 | return self::valid($validContent); |
103 | 103 | }, |
104 | - function (array $messages) use ($map) { |
|
104 | + function(array $messages) use ($map) { |
|
105 | 105 | return self::errors($map($messages)); |
106 | 106 | } |
107 | 107 | ); |
@@ -28,8 +28,7 @@ discard block |
||
28 | 28 | { |
29 | 29 | $this->pattern = $pattern; |
30 | 30 | $this->errorFormatter = is_callable($errorFormatter) ? |
31 | - $errorFormatter : |
|
32 | - function (string $key, $data) { |
|
31 | + $errorFormatter : function(string $key, $data) { |
|
33 | 32 | return [self::MATCH_FAILED]; |
34 | 33 | }; |
35 | 34 | } |
@@ -48,7 +47,7 @@ discard block |
||
48 | 47 | { |
49 | 48 | return new self( |
50 | 49 | $pattern, |
51 | - function (string $key, $data) use ($translator) { |
|
50 | + function(string $key, $data) use ($translator) { |
|
52 | 51 | return [$translator->translate(self::MATCH_FAILED)]; |
53 | 52 | } |
54 | 53 | ); |
@@ -27,8 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $this->assertion = $assertion; |
29 | 29 | $this->errorFormatter = is_callable($errorFormatter) ? |
30 | - $errorFormatter : |
|
31 | - function ($data) { |
|
30 | + $errorFormatter : function($data) { |
|
32 | 31 | return [self::NOT_AS_ASSERTED]; |
33 | 32 | }; |
34 | 33 | } |
@@ -47,7 +46,7 @@ discard block |
||
47 | 46 | { |
48 | 47 | return new self( |
49 | 48 | $assertion, |
50 | - function ($data) use ($translator) { |
|
49 | + function($data) use ($translator) { |
|
51 | 50 | return [$translator->translate(self::NOT_AS_ASSERTED)]; |
52 | 51 | } |
53 | 52 | ); |
@@ -55,7 +54,7 @@ discard block |
||
55 | 54 | |
56 | 55 | public function validate($data, array $context = []): ValidationResult |
57 | 56 | { |
58 | - if (! ($this->assertion)($data)) { |
|
57 | + if (!($this->assertion)($data)) { |
|
59 | 58 | return ValidationResult::errors(($this->errorFormatter)($data)); |
60 | 59 | } |
61 | 60 |
@@ -28,8 +28,7 @@ discard block |
||
28 | 28 | { |
29 | 29 | $this->key = $key; |
30 | 30 | $this->errorFormatter = is_callable($errorFormatter) ? |
31 | - $errorFormatter : |
|
32 | - function (string $key, $data) { |
|
31 | + $errorFormatter : function(string $key, $data) { |
|
33 | 32 | return [self::MISSING_KEY]; |
34 | 33 | }; |
35 | 34 | } |
@@ -48,7 +47,7 @@ discard block |
||
48 | 47 | { |
49 | 48 | return new self( |
50 | 49 | $key, |
51 | - function (string $key, $data) use ($translator) { |
|
50 | + function(string $key, $data) use ($translator) { |
|
52 | 51 | return [$translator->translate(self::MISSING_KEY)]; |
53 | 52 | } |
54 | 53 | ); |
@@ -56,7 +55,7 @@ discard block |
||
56 | 55 | |
57 | 56 | public function validate($data, array $context = []): ValidationResult |
58 | 57 | { |
59 | - if (! array_key_exists($this->key, $data)) { |
|
58 | + if (!array_key_exists($this->key, $data)) { |
|
60 | 59 | return ValidationResult::errors(($this->errorFormatter)($this->key, $data)); |
61 | 60 | } |
62 | 61 |