eventRecorder->record(new DemoAggregateEvent($id)); return new self($root); } public static function rehydrate(AggregateId $id, iterable $events): self { $root = AggregateRoot::rehydrate($id, new AggregateState(), $events); return new self($root); } public function eventHappened(DemoAggregateEvent $event): void { $this->root->applyAndRecord($event); } }