Debian Codegraph @

lib/3rdParty/composer/facile-it/php-jose-verifier/src/Internal/Checker/NonceChecker.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Facile\JoseVerifier\Internal\Checker;
6
7 use Jose\Component\Checker\ClaimChecker;
8 use Jose\Component\Checker\InvalidClaimException;
9
10 use function sprintf;
11
12 /**
13 * @internal
14 */
15 final class NonceChecker implements ClaimChecker
16 {
17 private const CLAIM_NAME = 'nonce';
18
19 private string $nonce;
20
21 public function __construct(string $nonce)
22 {
23 $this->nonce = $nonce;
24 }
25
26 /**
27 * @param mixed $value
28 *
29 * @throws InvalidClaimException
30 */
31 public function checkClaim($value): void
32 {
33 if ($value !== $this->nonce) {
34 throw new InvalidClaimException(sprintf('Nonce mismatch, expected %s, got: %s', $this->nonce, (string) $value), self::CLAIM_NAME, $value);
35 }
36 }
37
38 public function supportedClaim(): string
39 {
40 return self::CLAIM_NAME;
41 }
42 }