/** * @param PostTodo $command * @throws \Prooph\ProophessorDo\Model\User\Exception\UserNotFound */ public function __invoke(PostTodo $command) { $user = $this->userCollection->get($command->assigneeId()); if (!$user) { throw UserNotFound::withUserId($command->assigneeId()); } $todo = $user->postTodo($command->text(), $command->todoId()); $this->todoList->add($todo); }
/** * @param RegisterUser $command */ public function __invoke(RegisterUser $command) { $user = User::registerWithData($command->userId(), $command->name(), $command->emailAddress()); $this->userCollection->add($user); }