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

@@ 213-227 (lines=15) @@
210
            return $input;
211
        }
212
213
        foreach ($this->getChildren() as $field => $config) {
214
            if (!array_key_exists($field, $input)) {
215
                if ($config->isRequired()) {
216
                    throw new RequiredFieldException($field);
217
                }
218
219
                if (!$config->hasDefault()) {
220
                    continue;
221
                }
222
223
                $input[$field] = $config->getDefault();
224
            }
225
226
            $result[$field] = $config->getValue($field, $config->walk($input[$field]));
227
        }
228
229
        return $result;
230
    }