time = $time ?? new \DateTime(); $this->villageId = $villageId; } /* OOP */ public function cast(): Event { $class = Event::resolveType($this->type); $object = new $class(); return Model::castToType($this, Event::resolveType($this->type)); } public static function resolveType(string $type): string { return __NAMESPACE__ . '\\Event\\' . $type; } }