Completed
Push — master ( 2978b4...deca97 )
by Thomas Mauro
01:55
created

AuthSession   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 84
ccs 33
cts 33
cp 1
rs 10
c 0
b 0
f 0
wmc 10
lcom 1
cbo 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getState() 0 4 1
A getNonce() 0 4 1
A getCodeVerifier() 0 4 1
A getCustoms() 0 4 1
A setState() 0 4 1
A setNonce() 0 4 1
A setCodeVerifier() 0 4 1
A setCustoms() 0 4 1
A fromArray() 0 10 1
A jsonSerialize() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClient\Session;
6
7
use function array_filter;
8
9
final class AuthSession implements AuthSessionInterface
10
{
11
    /** @var null|string */
12
    private $state;
13
14
    /** @var null|string */
15
    private $nonce;
16
17
    /** @var null|string */
18
    private $codeVerifier;
19
20
    /** @var array<string, mixed> */
21
    private $customs = [];
22
23 3
    public function getState(): ?string
24
    {
25 3
        return $this->state;
26
    }
27
28 3
    public function getNonce(): ?string
29
    {
30 3
        return $this->nonce;
31
    }
32
33 2
    public function getCodeVerifier(): ?string
34
    {
35 2
        return $this->codeVerifier;
36
    }
37
38
    /**
39
     * @return array<string, mixed>
0 ignored issues
show
Documentation introduced by
The doc-type array<string, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
40
     */
41 2
    public function getCustoms(): array
42
    {
43 2
        return $this->customs;
44
    }
45
46 3
    public function setState(?string $state): void
47
    {
48 3
        $this->state = $state;
49 3
    }
50
51 3
    public function setNonce(?string $nonce): void
52
    {
53 3
        $this->nonce = $nonce;
54 3
    }
55
56 3
    public function setCodeVerifier(?string $codeVerifier): void
57
    {
58 3
        $this->codeVerifier = $codeVerifier;
59 3
    }
60
61
    /**
62
     * @param array<string, mixed> $customs
63
     */
64 3
    public function setCustoms(array $customs): void
65
    {
66 3
        $this->customs = $customs;
67 3
    }
68
69 2
    public static function fromArray(array $array): AuthSessionInterface
70
    {
71 2
        $session = new static();
72 2
        $session->setState($array['state'] ?? null);
73 2
        $session->setNonce($array['nonce'] ?? null);
74 2
        $session->setCodeVerifier($array['code_verifier'] ?? null);
75 2
        $session->setCustoms($array['customs'] ?? []);
76
77 2
        return $session;
78
    }
79
80
    /**
81
     * @return array<string, mixed>
0 ignored issues
show
Documentation introduced by
The doc-type array<string, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
82
     */
83 1
    public function jsonSerialize(): array
84
    {
85 1
        return array_filter([
86 1
            'state' => $this->getState(),
87 1
            'nonce' => $this->getNonce(),
88 1
            'code_verifier' => $this->getCodeVerifier(),
89 1
            'customs' => $this->getCustoms(),
90
        ]);
91
    }
92
}
93