Passed
Push — master ( 106006...c1ddb5 )
by Thomas Mauro
06:38 queued 11s
created

AzpChecker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A checkClaim() 0 4 2
A supportedClaim() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\OpenIdClient\ClaimChecker;
6
7
use Jose\Component\Checker\ClaimChecker;
8
use Jose\Component\Checker\InvalidClaimException;
9
use function sprintf;
10
11
final class AzpChecker implements ClaimChecker
12
{
13
    private const CLAIM_NAME = 'azp';
14
15
    /** @var string */
16
    private $azp;
17
18 36
    public function __construct(string $azp)
19
    {
20 36
        $this->azp = $azp;
21 36
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 2
    public function checkClaim($value): void
27
    {
28 2
        if ($value !== $this->azp) {
29 1
            throw new InvalidClaimException(sprintf('azp must be the client_id, expected %s, got: %s', $this->azp, $value), self::CLAIM_NAME, $value);
30
        }
31 1
    }
32
33 34
    public function supportedClaim(): string
34
    {
35 34
        return self::CLAIM_NAME;
36
    }
37
}
38