| @@ 181-195 (lines=15) @@ | ||
| 178 | return $input; |
|
| 179 | } |
|
| 180 | ||
| 181 | foreach ($this->getChildren() as $field => $config) { |
|
| 182 | if (!array_key_exists($field, $input)) { |
|
| 183 | if ($config->isRequired()) { |
|
| 184 | throw new RequiredFieldException($field); |
|
| 185 | } |
|
| 186 | ||
| 187 | if (!$config->hasDefault()) { |
|
| 188 | continue; |
|
| 189 | } |
|
| 190 | ||
| 191 | $input[$field] = $config->getDefault(); |
|
| 192 | } |
|
| 193 | ||
| 194 | $result[$field] = $config->getValue($field, $config->walk($input[$field])); |
|
| 195 | } |
|
| 196 | ||
| 197 | return $result; |
|
| 198 | } |
|
| @@ 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 | } |
|