Conditions | 4 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 10 |
Lines | 8 |
Ratio | 36.36 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
23 | public function hydrateObject(\stdClass $input) |
||
24 | { |
||
25 | $object = (object)[]; |
||
26 | |||
27 | /** @var ObjectSchema $objectSchema */ |
||
28 | $objectSchema = $this->schema; |
||
29 | |||
30 | /** |
||
31 | * @var string $name |
||
32 | * @var Schema $propertySchema |
||
33 | */ |
||
34 | View Code Duplication | foreach ($objectSchema->getPropertySchemas() as $name => $propertySchema) { |
|
35 | if (!isset($input->$name) && isset($this->defaults[$name])) { |
||
36 | $value = $this->defaults[$name]; |
||
37 | } else { |
||
38 | $value = $input->$name; |
||
39 | } |
||
40 | $object->$name = $this->hydrateProperty($name, $value); |
||
41 | } |
||
42 | |||
43 | return $object; |
||
44 | } |
||
45 | |||
67 |