@@ -26,11 +26,11 @@ |
||
26 | 26 | |
27 | 27 | $builder->withErrorsLevelMask($errorsLevelMask); |
28 | 28 | |
29 | - if($withBaseFilters) { |
|
29 | + if ($withBaseFilters) { |
|
30 | 30 | $builder->withFilters(new BaseFiltersStorage()); |
31 | 31 | } |
32 | 32 | |
33 | - if($extraFilters !== null) { |
|
33 | + if ($extraFilters !== null) { |
|
34 | 34 | $builder->withFilters($extraFilters); |
35 | 35 | } |
36 | 36 |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | { |
69 | 69 | $toAccessor = $this->nestedAccessorFactory->create($result, $this->pathDelimiter); |
70 | 70 | |
71 | - foreach($schema as $keyTo => $keyFrom) { |
|
71 | + foreach ($schema as $keyTo => $keyFrom) { |
|
72 | 72 | $value = $this->getValue($source, $keyFrom); |
73 | - if($keyTo === '') { |
|
73 | + if ($keyTo === '') { |
|
74 | 74 | return $value; |
75 | 75 | } |
76 | 76 | $toAccessor->set($keyTo, $value); |
@@ -84,19 +84,19 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getValue($source, $key) |
86 | 86 | { |
87 | - if($key === '' || $key === null) { |
|
87 | + if ($key === '' || $key === null) { |
|
88 | 88 | return $source; |
89 | 89 | } |
90 | 90 | |
91 | - if($source === null || (!is_array($source) && !is_object($source))) { |
|
91 | + if ($source === null || (!is_array($source) && !is_object($source))) { |
|
92 | 92 | return $this->getValueFromUnsupportedSource($source, $key); |
93 | 93 | } |
94 | 94 | |
95 | - if(is_string($key)) { |
|
95 | + if (is_string($key)) { |
|
96 | 96 | return $this->getValueByKey($source, $key); |
97 | 97 | } |
98 | 98 | |
99 | - if(is_array($key)) { |
|
99 | + if (is_array($key)) { |
|
100 | 100 | return $this->getValueByFilters($source, $key); |
101 | 101 | } |
102 | 102 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $key, |
144 | 144 | BitmapHelper::intersects($this->errorsLevelMask, [SchematorException::CANNOT_GET_VALUE]) |
145 | 145 | ); |
146 | - } catch(NestedAccessorException $e) { |
|
146 | + } catch (NestedAccessorException $e) { |
|
147 | 147 | throw SchematorException::createAsCannotGetValue($source, $key, $e); |
148 | 148 | } |
149 | 149 | } |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | protected function getValueByFilters($source, array $filters) |
159 | 159 | { |
160 | 160 | $result = $source; |
161 | - foreach($filters as $filterConfig) { |
|
162 | - if(is_string($filterConfig)) { |
|
161 | + foreach ($filters as $filterConfig) { |
|
162 | + if (is_string($filterConfig)) { |
|
163 | 163 | $result = $this->getValue($result, $filterConfig); |
164 | - } elseif(is_array($filterConfig)) { |
|
164 | + } elseif (is_array($filterConfig)) { |
|
165 | 165 | $result = $this->runFilter($filterConfig, $result, $source); |
166 | 166 | } else { |
167 | - if( |
|
167 | + if ( |
|
168 | 168 | BitmapHelper::intersects( |
169 | 169 | $this->errorsLevelMask, |
170 | 170 | [SchematorException::UNSUPPORTED_FILTER_CONFIG_TYPE] |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | protected function getValueFromUnsupportedSource($source, $key) |
190 | 190 | { |
191 | - if(BitmapHelper::intersects($this->errorsLevelMask, [SchematorException::UNSUPPORTED_SOURCE_TYPE])) { |
|
191 | + if (BitmapHelper::intersects($this->errorsLevelMask, [SchematorException::UNSUPPORTED_SOURCE_TYPE])) { |
|
192 | 192 | throw SchematorException::createAsUnsupportedSourceType($source, $key); |
193 | 193 | } |
194 | 194 | return null; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | protected function getValueByUnsupportedKey($source, $key) |
205 | 205 | { |
206 | - if(BitmapHelper::intersects($this->errorsLevelMask, [SchematorException::UNSUPPORTED_KEY_TYPE])) { |
|
206 | + if (BitmapHelper::intersects($this->errorsLevelMask, [SchematorException::UNSUPPORTED_KEY_TYPE])) { |
|
207 | 207 | throw SchematorException::createAsUnsupportedKeyType($source, $key); |
208 | 208 | } |
209 | 209 | return null; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | { |
222 | 222 | $filterName = strval(array_shift($filterConfig)); |
223 | 223 | |
224 | - if( |
|
224 | + if ( |
|
225 | 225 | !isset($this->filterMap[$filterName]) |
226 | 226 | && BitmapHelper::intersects($this->errorsLevelMask, [SchematorException::FILTER_NOT_FOUND]) |
227 | 227 | ) { |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | new FilterContext($this, $source, $rootSource), |
234 | 234 | ...$filterConfig |
235 | 235 | ); |
236 | - } catch(Throwable $e) { |
|
237 | - if(BitmapHelper::intersects($this->errorsLevelMask, [SchematorException::FILTER_ERROR])) { |
|
236 | + } catch (Throwable $e) { |
|
237 | + if (BitmapHelper::intersects($this->errorsLevelMask, [SchematorException::FILTER_ERROR])) { |
|
238 | 238 | throw SchematorException::createAsFilterError($filterName, $filterConfig, $source, $e); |
239 | 239 | } |
240 | 240 | return null; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function generate(iterable $source, array $schema): Generator |
34 | 34 | { |
35 | - foreach($source as $item) { |
|
35 | + foreach ($source as $item) { |
|
36 | 36 | yield $this->schemator->convert($item, $schema); |
37 | 37 | } |
38 | 38 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $gen = $this->generate($source, $schema); |
46 | 46 | $result = []; |
47 | 47 | |
48 | - foreach($gen as $item) { |
|
48 | + foreach ($gen as $item) { |
|
49 | 49 | $result[] = $item; |
50 | 50 | } |
51 | 51 |