protected function urlSafeEncode($data)
    {
        if (\is_array($data)) {
            $data = \json_encode($data, \JSON_UNESCAPED_SLASHES);
            $this->validateLastJson();
        }

        return \rtrim(\strtr(\base64_encode($data), '+/', '-_'), '=');
    }
protected function urlSafeEncode($data)
    {
        if (\is_array($data)) {
            $data = \json_encode($data, \JSON_UNESCAPED_SLASHES);
            $this->validateLastJson();
        }

        return \rtrim(\strtr(\base64_encode($data), '+/', '-_'), '=');
    }
protected function urlSafeEncode ( $ data ) { if ( \ is_array ( $ data ) ) { $ data = \ json_encode ( $ data , \ JSON_UNESCAPED_SLASHES ) ; $ this -> validateLastJson ( ) ; } return \ rtrim ( \ strtr ( \ base64_encode ( $ data ) , '+/' , '-_' ) , '=' ) ; }
URL safe base64 encode.

First serialized the payload as json if it is an array.

@param array|string $data

@throws JWTException When JSON encode fails.

@return string
URL safe base64 encode .