Code Duplication    Length = 15-15 lines in 2 locations

src/Node/CollectionNode.php 1 location

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

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
    }