/** * * @param User $user * @throws \Veloci\User\Exception\ValidationException */ public function signup(User $user) { $this->modelValidator->validate($user); if ($this->userRepository->usernameAlreadyExists($user->getUsername())) { throw new ValidationException(['username' => 'duplicated']); } $this->userRepository->save($user); }