public function register($login, $password) { if ($this->userRepository->findBySpecification(new LoginSpecification($login))) { throw new UserAlreadyExistsException(sprintf('User "%s" already exists', $login)); } $user = new User($login, $password); $this->userRepository->add($user); $this->uow->commit(); return $user; }