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 function handle(RewardUserCommand $command) { $user = $this->userRepository->byId(UserId::fromString($command->userId())); $user->earnPoints($command->points()); $this->userRepository->save($user); }