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

Client   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 66
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getMetadata() 0 3 1
A __construct() 0 17 3
A getJwks() 0 3 1
A getIssuer() 0 3 1
A getAuthMethodFactory() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\OpenIdClient\Client;
6
7
use Jose\Component\Core\JWKSet;
8
use TMV\OpenIdClient\AuthMethod\AuthMethodFactory;
9
use TMV\OpenIdClient\AuthMethod\AuthMethodFactoryInterface;
10
use TMV\OpenIdClient\AuthMethod\ClientSecretBasic;
11
use TMV\OpenIdClient\AuthMethod\ClientSecretJwt;
12
use TMV\OpenIdClient\AuthMethod\ClientSecretPost;
13
use TMV\OpenIdClient\AuthMethod\None;
14
use TMV\OpenIdClient\AuthMethod\PrivateKeyJwt;
15
use TMV\OpenIdClient\AuthMethod\SelfSignedTLSClientAuth;
16
use TMV\OpenIdClient\AuthMethod\TLSClientAuth;
17
use TMV\OpenIdClient\Client\Metadata\ClientMetadataInterface;
18
use TMV\OpenIdClient\Issuer\IssuerInterface;
19
20
final class Client implements ClientInterface
21
{
22
    /** @var IssuerInterface */
23
    private $issuer;
24
25
    /** @var ClientMetadataInterface */
26
    private $metadata;
27
28
    /** @var JWKSet */
29
    private $jwks;
30
31
    /** @var AuthMethodFactoryInterface */
32
    private $authMethodFactory;
33
34
    /**
35
     * Client constructor.
36
     *
37
     * @param IssuerInterface $issuer
38
     * @param ClientMetadataInterface $metadata
39
     * @param null|JWKSet $jwks
40
     * @param null|AuthMethodFactoryInterface $authMethodFactory
41
     */
42 2
    public function __construct(
43
        IssuerInterface $issuer,
44
        ClientMetadataInterface $metadata,
45
        ?JWKSet $jwks = null,
46
        ?AuthMethodFactoryInterface $authMethodFactory = null
47
    ) {
48 2
        $this->issuer = $issuer;
49 2
        $this->metadata = $metadata;
50 2
        $this->jwks = $jwks ?: new JWKSet([]);
51 2
        $this->authMethodFactory = $authMethodFactory ?: new AuthMethodFactory([
52 1
            new ClientSecretBasic(),
53 1
            new ClientSecretJwt(),
54 1
            new ClientSecretPost(),
55 1
            new None(),
56 1
            new PrivateKeyJwt(),
57 1
            new TLSClientAuth(),
58 1
            new SelfSignedTLSClientAuth(),
59
        ]);
60 2
    }
61
62
    /**
63
     * @return IssuerInterface
64
     */
65 2
    public function getIssuer(): IssuerInterface
66
    {
67 2
        return $this->issuer;
68
    }
69
70 2
    public function getMetadata(): ClientMetadataInterface
71
    {
72 2
        return $this->metadata;
73
    }
74
75 2
    public function getJwks(): JWKSet
76
    {
77 2
        return $this->jwks;
78
    }
79
80
    /**
81
     * @return AuthMethodFactoryInterface
82
     */
83 2
    public function getAuthMethodFactory(): AuthMethodFactoryInterface
84
    {
85 2
        return $this->authMethodFactory;
86
    }
87
}
88