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);
    }