Issuer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 40
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getJwks() 0 3 1
A updateJwks() 0 3 1
A __construct() 0 10 2
A getMetadata() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\OpenIdClient\Issuer;
6
7
use Http\Discovery\Psr17FactoryDiscovery;
8
use Http\Discovery\Psr18ClientDiscovery;
9
use Jose\Component\Core\JWKSet;
10
use Jose\Component\KeyManagement\JKUFactory;
11
use TMV\OpenIdClient\Issuer\Metadata\IssuerMetadataInterface;
12
13
final class Issuer implements IssuerInterface
14
{
15
    /** @var IssuerMetadataInterface */
16
    private $metadata;
17
18
    /** @var JWKSet */
19
    private $jwks;
20
21
    /** @var JKUFactory */
22
    private $JKUFactory;
23
24 4
    public function __construct(
25
        IssuerMetadataInterface $metadata,
26
        JWKSet $jwks,
27
        ?JKUFactory $JKUFactory = null
28
    ) {
29 4
        $this->metadata = $metadata;
30 4
        $this->jwks = $jwks;
31 4
        $this->JKUFactory = $JKUFactory ?: new JKUFactory(
32 1
            Psr18ClientDiscovery::find(),
33 1
            Psr17FactoryDiscovery::findRequestFactory()
34
        );
35 4
    }
36
37 3
    public function getMetadata(): IssuerMetadataInterface
38
    {
39 3
        return $this->metadata;
40
    }
41
42
    /**
43
     * @return JWKSet
44
     */
45 2
    public function getJwks(): JWKSet
46
    {
47 2
        return $this->jwks;
48
    }
49
50 1
    public function updateJwks(): void
51
    {
52 1
        $this->jwks = $this->JKUFactory->loadFromUrl($this->metadata->getJwksUri());
53 1
    }
54
}
55