@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | $this->keyPath = $this->buildKey($keyPath); |
31 | 31 | $this->value = RecursiveStructureAccess::recursiveGet($data, $this->keyPath, null); |
32 | 32 | $this->hasValue = is_scalar($this->value) ? trim((string) $this->value) !== '' : !empty($this->value); |
33 | - if($validator === null) { |
|
33 | + if ($validator === null) { |
|
34 | 34 | $validator = function() { |
35 | 35 | return true; |
36 | 36 | }; |
37 | 37 | } |
38 | 38 | $this->validator = $validator; |
39 | - if($validationResultHandler === null) { |
|
40 | - $validationResultHandler = static function () {}; |
|
39 | + if ($validationResultHandler === null) { |
|
40 | + $validationResultHandler = static function() {}; |
|
41 | 41 | } |
42 | 42 | $this->validationResultHandler = $validationResultHandler; |
43 | 43 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @return bool |
54 | 54 | */ |
55 | 55 | public function isValid(): bool { |
56 | - if(!$this->hasValue) { |
|
56 | + if (!$this->hasValue) { |
|
57 | 57 | return false; |
58 | 58 | } |
59 | - if($this->validator !== null) { |
|
59 | + if ($this->validator !== null) { |
|
60 | 60 | $result = call_user_func($this->validator, $this->value); |
61 | 61 | call_user_func($this->validationResultHandler, $result, [ |
62 | 62 | 'value' => $this->value, |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | * @return string[] |
80 | 80 | */ |
81 | 81 | private function buildKey($keyPath): array { |
82 | - if(is_string($keyPath)) { |
|
82 | + if (is_string($keyPath)) { |
|
83 | 83 | $keyPath = explode('.', $keyPath); |
84 | 84 | } |
85 | - if(!is_array($keyPath)) { |
|
85 | + if (!is_array($keyPath)) { |
|
86 | 86 | throw new RuntimeException('Invalid key'); |
87 | 87 | } |
88 | 88 | return $keyPath; |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @return bool |
94 | 94 | */ |
95 | 95 | private function isValidArray(array $array): bool { |
96 | - $data = array_filter($array, function ($value) { |
|
97 | - if(is_array($value)) { |
|
96 | + $data = array_filter($array, function($value) { |
|
97 | + if (is_array($value)) { |
|
98 | 98 | return $this->isValidArray($value); |
99 | 99 | } |
100 | 100 | return (string) $value !== ''; |