Code Duplication    Length = 15-15 lines in 2 locations

src/Node/BaseNode.php 1 location

@@ 267-281 (lines=15) @@
264
            return $input;
265
        }
266
267
        foreach ($this->getChildren() as $field => $config) {
268
            if (!array_key_exists($field, $input)) {
269
                if ($config->isRequired()) {
270
                    throw new RequiredFieldException($field);
271
                }
272
273
                if (!$config->hasDefault()) {
274
                    continue;
275
                }
276
277
                $input[$field] = $config->getDefault();
278
            }
279
280
            $result[$field] = $config->getValue($field, $config->walk($input[$field]));
281
        }
282
283
        return $result;
284
    }

src/Node/CollectionNode.php 1 location

@@ 40-54 (lines=15) @@
37
38
            $itemResult = [];
39
40
            foreach ($this->getChildren() as $field => $config) {
41
                if (!array_key_exists($field, $inputItem)) {
42
                    if ($config->isRequired()) {
43
                        throw new RequiredFieldException($field);
44
                    }
45
46
                    if (!$config->hasDefault()) {
47
                        continue;
48
                    }
49
50
                    $inputItem[$field] = $config->getDefault();
51
                }
52
53
                $itemResult[$field] = $config->getValue($field, $config->walk($inputItem[$field]));
54
            }
55
56
            $result[] = $itemResult;
57
        }