public function twiddle($string, $index, $value, $encode = false) {
        $parts = explode(static::SEP, $string);

        if ($encode) {
            $value = static::base64urlEncode($value);
        }
        $parts[$index] = $value;

        return implode(static::SEP, $parts);
    }