public function verify(Signer $signer, $key)
    {
        if ($this->signature === null) {
            throw new \BadMethodCallException('This token is not signed');
        }

        if ($this->headers['alg'] !== $signer->getAlgorithmId()) {
            return false;
        }

        return $this->signature->verify($signer, $this->getPayload(), $key);
    }
public function verify(Signer $signer, $key)
    {
        if ($this->signature === null) {
            throw new \BadMethodCallException('This token is not signed');
        }

        if ($this->headers['alg'] !== $signer->getAlgorithmId()) {
            return false;
        }

        return $this->signature->verify($signer, $this->getPayload(), $key);
    }
public function verify ( Signer $ signer , $ key ) { if ( $ this -> signature === null ) { throw new \ BadMethodCallException ( 'This token is not signed' ) ; } if ( $ this -> headers [ 'alg' ] !== $ signer -> getAlgorithmId ( ) ) { return false ; } return $ this -> signature -> verify ( $ signer , $ this -> getPayload ( ) , $ key ) ; }
Verify if the key matches with the one that created the signature

@param Signer $signer
@param string $key

@return boolean

@throws \BadMethodCallException When token is not signed
Verify if the key matches with the one that created the signature