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

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