Code Duplication    Length = 15-15 lines in 2 locations

src/Node/CollectionNode.php 1 location

@@ 34-48 (lines=15) @@
31
        foreach ($input as $inputItem) {
32
            $itemResult = [];
33
34
            foreach ($this->getChildren() as $field => $config) {
35
                if (!array_key_exists($field, $inputItem)) {
36
                    if ($config->isRequired()) {
37
                        throw new RequiredFieldException($field);
38
                    }
39
40
                    if (!$config->hasDefault()) {
41
                        continue;
42
                    }
43
44
                    $inputItem[$field] = $config->getDefault();
45
                }
46
47
                $itemResult[$field] = $config->getValue($field, $config->walk($inputItem[$field]));
48
            }
49
50
            $result[] = $itemResult;
51
        }

src/Node/BaseNode.php 1 location

@@ 228-242 (lines=15) @@
225
            return $input;
226
        }
227
228
        foreach ($this->getChildren() as $field => $config) {
229
            if (!array_key_exists($field, $input)) {
230
                if ($config->isRequired()) {
231
                    throw new RequiredFieldException($field);
232
                }
233
234
                if (!$config->hasDefault()) {
235
                    continue;
236
                }
237
238
                $input[$field] = $config->getDefault();
239
            }
240
241
            $result[$field] = $config->getValue($field, $config->walk($input[$field]));
242
        }
243
244
        return $result;
245
    }