protected static function normalizeHost(?string $host): ?string
    {
        if ($host === null) {
            return null;
        }

        if ($host === '') {
            return '';
        }

        if (!static::isValidHost($host)) {
            $message = sprintf('Invalid host: %s', $host);
            throw new DomainException($message);
        }

        // Although host is case-insensitive, producers and normalizers should
        // use lowercase for registered names and hexadecimal addresses for the
        // sake of uniformity, while only using uppercase letters for
        // percent-encodings.
        $host = mb_strtolower($host, 'UTF-8');

        return static::encodeHost(static::decode($host, static::UNRESERVED_SET));
    }