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

        if (!static::isValidUserInfo($userInfo)) {
            $message = sprintf('Invalid user info: %s', $userInfo);
            throw new DomainException($message);
        }

        return static::encodeUserInfo(static::decode($userInfo, static::UNRESERVED_SET));
    }