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);
    }
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);
    }
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 ) ; }
Twiddle a value in an encoded secure string to another value.

This method is mainly for testing so that an invalid string can be created.

@param string $string A valid cookie to twiddle.
@param int $index The index of the new value.
@param string $value The new value. This will be base64url encoded.
@param bool $encode Whether or not to base64 url encode the value.
@return string Returns the new encoded cookie.
Twiddle a value in an encoded secure string to another value .