/** * Verify if the key matches with the one that created the signature * * @param Signer $signer * @param Key|string $key * * @return bool */ public function verify(Signer $signer, $key) : bool { if ($this->signature === null || $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 */ 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); }