Passed
Push — master ( c3d303...603419 )
by Smoren
01:46
created
src/Components/Schemator.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 $key,
145 145
                 $this->needToThrow(SchematorException::CANNOT_GET_VALUE)
146 146
             );
147
-        } catch(NestedAccessorException $e) {
147
+        } catch (NestedAccessorException $e) {
148 148
             throw SchematorException::createAsCannotGetValue($source, $key, $e);
149 149
         }
150 150
     }
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
     protected function getValueByFilters($source, array $filters)
160 160
     {
161 161
         $result = $source;
162
-        foreach($filters as $filterConfig) {
163
-            if(is_string($filterConfig)) {
162
+        foreach ($filters as $filterConfig) {
163
+            if (is_string($filterConfig)) {
164 164
                 $result = $this->getValue($result, $filterConfig);
165
-            } elseif(is_array($filterConfig)) {
165
+            } elseif (is_array($filterConfig)) {
166 166
                 $result = $this->runFilter($filterConfig, $result, $source);
167 167
             } else {
168
-                if($this->needToThrow(SchematorException::UNSUPPORTED_FILTER_CONFIG_TYPE)) {
168
+                if ($this->needToThrow(SchematorException::UNSUPPORTED_FILTER_CONFIG_TYPE)) {
169 169
                     throw SchematorException::createAsUnsupportedFilterConfigType($filterConfig);
170 170
                 }
171 171
                 $result = null;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     protected function getValueFromUnsupportedSource($source, $key)
186 186
     {
187
-        if($this->needToThrow(SchematorException::UNSUPPORTED_SOURCE_TYPE)) {
187
+        if ($this->needToThrow(SchematorException::UNSUPPORTED_SOURCE_TYPE)) {
188 188
             throw SchematorException::createAsUnsupportedSourceType($source, $key);
189 189
         }
190 190
         return null;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      */
200 200
     protected function getValueByUnsupportedKey($source, $key)
201 201
     {
202
-        if($this->needToThrow(SchematorException::UNSUPPORTED_KEY_TYPE)) {
202
+        if ($this->needToThrow(SchematorException::UNSUPPORTED_KEY_TYPE)) {
203 203
             throw SchematorException::createAsUnsupportedKeyType($source, $key);
204 204
         }
205 205
         return null;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     {
218 218
         $filterName = strval(array_shift($filterConfig));
219 219
 
220
-        if(
220
+        if (
221 221
             !isset($this->filterMap[$filterName])
222 222
             && $this->needToThrow(SchematorException::FILTER_NOT_FOUND)
223 223
         ) {
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
                 new FilterContext($this, $source, $rootSource),
230 230
                 ...$filterConfig
231 231
             );
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($filterName, $filterConfig, $source, $e);
240 240
             }
241 241
             return null;
Please login to merge, or discard this patch.