@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | { |
62 | 62 | $toAccessor = $this->nestedAccessorFactory->create($result, $this->pathDelimiter); |
63 | 63 | |
64 | - foreach($schema as $keyTo => $keyFrom) { |
|
64 | + foreach ($schema as $keyTo => $keyFrom) { |
|
65 | 65 | $value = $this->getValue($source, $keyFrom); |
66 | - if($keyTo === '') { |
|
66 | + if ($keyTo === '') { |
|
67 | 67 | return $value; |
68 | 68 | } |
69 | 69 | $toAccessor->set($keyTo, $value); |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function getValue($source, $key) |
80 | 80 | { |
81 | - if($key === '' || $key === null) { |
|
81 | + if ($key === '' || $key === null) { |
|
82 | 82 | return $source; |
83 | 83 | } |
84 | 84 | |
85 | - if(!is_array($source) && !is_object($source)) { |
|
85 | + if (!is_array($source) && !is_object($source)) { |
|
86 | 86 | return $this->getValueFromUnsupportedSource($source, $key); |
87 | 87 | } |
88 | 88 | |
89 | - if(is_string($key)) { |
|
89 | + if (is_string($key)) { |
|
90 | 90 | return $this->getValueByKey($source, $key); |
91 | 91 | } |
92 | 92 | |
93 | - if(is_array($key)) { |
|
93 | + if (is_array($key)) { |
|
94 | 94 | return $this->getValueByFilters($source, $key); |
95 | 95 | } |
96 | 96 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $key, |
139 | 139 | $this->needToThrow(SchematorException::CANNOT_GET_VALUE) |
140 | 140 | ); |
141 | - } catch(NestedAccessorException $e) { |
|
141 | + } catch (NestedAccessorException $e) { |
|
142 | 142 | throw SchematorException::createAsCannotGetValue($source, $key, $e); |
143 | 143 | } |
144 | 144 | } |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | protected function getValueByFilters($source, array $filters) |
154 | 154 | { |
155 | 155 | $result = $source; |
156 | - foreach($filters as $filterConfig) { |
|
157 | - if(is_string($filterConfig)) { |
|
156 | + foreach ($filters as $filterConfig) { |
|
157 | + if (is_string($filterConfig)) { |
|
158 | 158 | $result = $this->getValue($result, $filterConfig); |
159 | - } elseif(is_array($filterConfig)) { |
|
159 | + } elseif (is_array($filterConfig)) { |
|
160 | 160 | $result = $this->runFilter($filterConfig, $result, $source); |
161 | 161 | } else { |
162 | - if($this->needToThrow(SchematorException::UNSUPPORTED_FILTER_CONFIG_TYPE)) { |
|
162 | + if ($this->needToThrow(SchematorException::UNSUPPORTED_FILTER_CONFIG_TYPE)) { |
|
163 | 163 | throw SchematorException::createAsUnsupportedFilterConfigType($filterConfig); |
164 | 164 | } |
165 | 165 | $result = null; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | protected function getValueFromUnsupportedSource($source, $key) |
180 | 180 | { |
181 | - if($this->needToThrow(SchematorException::UNSUPPORTED_SOURCE_TYPE)) { |
|
181 | + if ($this->needToThrow(SchematorException::UNSUPPORTED_SOURCE_TYPE)) { |
|
182 | 182 | throw SchematorException::createAsUnsupportedSourceType($source, $key); |
183 | 183 | } |
184 | 184 | return null; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function getValueByUnsupportedKey($source, $key) |
195 | 195 | { |
196 | - if($this->needToThrow(SchematorException::UNSUPPORTED_KEY_TYPE)) { |
|
196 | + if ($this->needToThrow(SchematorException::UNSUPPORTED_KEY_TYPE)) { |
|
197 | 197 | throw SchematorException::createAsUnsupportedKeyType($source, $key); |
198 | 198 | } |
199 | 199 | return null; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | { |
212 | 212 | $filterName = strval(array_shift($filterConfig)); |
213 | 213 | |
214 | - if( |
|
214 | + if ( |
|
215 | 215 | !isset($this->filterMap[$filterName]) |
216 | 216 | && $this->needToThrow(SchematorException::FILTER_NOT_FOUND) |
217 | 217 | ) { |
@@ -224,18 +224,18 @@ discard block |
||
224 | 224 | $filterContext, |
225 | 225 | ...$filterConfig |
226 | 226 | ); |
227 | - } catch(TypeError $e) { |
|
228 | - if($this->needToThrow(SchematorException::BAD_FILTER_CONFIG)) { |
|
227 | + } catch (TypeError $e) { |
|
228 | + if ($this->needToThrow(SchematorException::BAD_FILTER_CONFIG)) { |
|
229 | 229 | throw SchematorException::createAsBadFilterConfig($filterContext, $e); |
230 | 230 | } |
231 | 231 | return null; |
232 | - } catch(SchematorException $e) { |
|
233 | - if($this->needToThrow($e->getCode())) { |
|
232 | + } catch (SchematorException $e) { |
|
233 | + if ($this->needToThrow($e->getCode())) { |
|
234 | 234 | throw $e; |
235 | 235 | } |
236 | 236 | return null; |
237 | - } catch(Throwable $e) { |
|
238 | - if($this->needToThrow(SchematorException::FILTER_ERROR)) { |
|
237 | + } catch (Throwable $e) { |
|
238 | + if ($this->needToThrow(SchematorException::FILTER_ERROR)) { |
|
239 | 239 | throw SchematorException::createAsFilterError($filterContext); |
240 | 240 | } |
241 | 241 | return null; |