Passed
Push — master ( 898cc7...450add )
by Thomas Mauro
03:07
created

AzpChecker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 25
ccs 0
cts 13
cp 0
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
10
final class AzpChecker implements ClaimChecker
11
{
12
    private const CLAIM_NAME = 'azp';
13
14
    /** @var string */
15
    private $azp;
16
17
    public function __construct(string $azp)
18
    {
19
        $this->azp = $azp;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function checkClaim($value): void
26
    {
27
        if ($value !== $this->azp) {
28
            throw new InvalidClaimException(\sprintf('azp must be the client_id, expected %s, got: %s', $this->azp, $value), self::CLAIM_NAME, $value);
29
        }
30
    }
31
32
    public function supportedClaim(): string
33
    {
34
        return self::CLAIM_NAME;
35
    }
36
}
37