Ejemplo n.º 1
0
 private function buildValueObject(ValueObject $meta, CollectionInterface $data)
 {
     $reflection = new ReflectionClass((string) $meta->class());
     $meta->properties()->foreach(function (string $name, Property $property) use(&$reflection, $data) {
         if ($property->type()->isNullable() && !$data->hasKey($name)) {
             return;
         }
         $reflection = $reflection->withProperty($name, $property->type()->fromDatabase($data->get($name)));
     });
     return $reflection->buildObject();
 }