public function handle(SignupCommand $command) { $userId = UserId::fromString($command->id()); if ($this->userRepository->has($userId)) { return; } $user = User::signup($userId); $this->userRepository->save($user); }
public static function signup(UserId $userId) { $user = new User($userId); $user->publishThat(new UserSignedUp($userId)); return $user; }
public function byId(UserId $id) { return User::reconstitute($this->eventstore->getEventsFor($id)); }