email === null) { throw new BadRequestException('email is required'); } if ($dto->password === null) { throw new BadRequestException('password is required'); } if (strlen($dto->password) < 8) { throw new BadRequestException( 'password must be at least 8 characters' ); } $email = new EmailAddress($dto->email); if ($this->userRepo->findByEmail($email) !== null) { throw new BadRequestException('email already taken'); } $this->userRepo->create(new CreateUserDto( email: $email, passwordHash: password_hash($dto->password, PASSWORD_DEFAULT), isAdmin: $dto->isAdmin, )); } }