protected function parse($token)
    {
        $result = new \stdClass();
        $result->violations = [];
        $result->payload = null;
        $segments = explode('.', $token);

        if (count($segments) !== 2) {
            $result->violations[] = new \InvalidArgumentException('Wrong number of segments');

            return $result;
        }

        list($payloadBase64, $signature) = $segments;

        $sign = $this->sign;

        if ($signature !== $sign($payloadBase64)) {
            $result->violations[] = new \InvalidArgumentException('Signature verification failed');
        }

        $result->payload = json_decode($this->base64url->decode($payloadBase64));

        if (!($result->payload instanceof \stdClass)) {
            $result->violations[] = new \InvalidArgumentException('Invalid payload encoding');
        }

        return $result;
    }
protected function parse($token)
    {
        $result = new \stdClass();
        $result->violations = [];
        $result->payload = null;
        $segments = explode('.', $token);

        if (count($segments) !== 2) {
            $result->violations[] = new \InvalidArgumentException('Wrong number of segments');

            return $result;
        }

        list($payloadBase64, $signature) = $segments;

        $sign = $this->sign;

        if ($signature !== $sign($payloadBase64)) {
            $result->violations[] = new \InvalidArgumentException('Signature verification failed');
        }

        $result->payload = json_decode($this->base64url->decode($payloadBase64));

        if (!($result->payload instanceof \stdClass)) {
            $result->violations[] = new \InvalidArgumentException('Invalid payload encoding');
        }

        return $result;
    }
protected function parse ( $ token ) { $ result = new \ stdClass ( ) ; $ result -> violations = [ ] ; $ result -> payload = null ; $ segments = explode ( '.' , $ token ) ; if ( count ( $ segments ) !== 2 ) { $ result -> violations [ ] = new \ InvalidArgumentException ( 'Wrong number of segments' ) ; return $ result ; } list ( $ payloadBase64 , $ signature ) = $ segments ; $ sign = $ this -> sign ; if ( $ signature !== $ sign ( $ payloadBase64 ) ) { $ result -> violations [ ] = new \ InvalidArgumentException ( 'Signature verification failed' ) ; } $ result -> payload = json_decode ( $ this -> base64url -> decode ( $ payloadBase64 ) ) ; if ( ! ( $ result -> payload instanceof \ stdClass ) ) { $ result -> violations [ ] = new \ InvalidArgumentException ( 'Invalid payload encoding' ) ; } return $ result ; }
Parse a CSRF token.

@param string $token The token to parse

@return \stdClass Parse result containing payload and constraint violations
Parse a CSRF token .