Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
14 / 14 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| InvalidClaimException | |
100.00% |
14 / 14 |
|
100.00% |
4 / 4 |
7 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
4 | |||
| getClaimName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getActualValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getExpectedValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace DevToolbelt\JwtTokenManager\Exceptions; |
| 6 | |
| 7 | final class InvalidClaimException extends JwtException |
| 8 | { |
| 9 | protected string $errorKey = 'invalidClaim'; |
| 10 | |
| 11 | public function __construct( |
| 12 | private readonly string $claimName, |
| 13 | private readonly mixed $actualValue, |
| 14 | private readonly mixed $expectedValue = null |
| 15 | ) { |
| 16 | $message = sprintf( |
| 17 | 'Invalid claim "%s": got "%s"', |
| 18 | $this->claimName, |
| 19 | is_array($this->actualValue) ? json_encode($this->actualValue) : (string) $this->actualValue |
| 20 | ); |
| 21 | |
| 22 | if ($this->expectedValue !== null) { |
| 23 | $message .= sprintf( |
| 24 | ', expected "%s"', |
| 25 | is_array($this->expectedValue) ? json_encode($this->expectedValue) : (string) $this->expectedValue |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | parent::__construct($message); |
| 30 | } |
| 31 | |
| 32 | public function getClaimName(): string |
| 33 | { |
| 34 | return $this->claimName; |
| 35 | } |
| 36 | |
| 37 | public function getActualValue(): mixed |
| 38 | { |
| 39 | return $this->actualValue; |
| 40 | } |
| 41 | |
| 42 | public function getExpectedValue(): mixed |
| 43 | { |
| 44 | return $this->expectedValue; |
| 45 | } |
| 46 | } |