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

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