AuthSession::fromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\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 3
    public function getState(): ?string
18
    {
19 3
        return $this->state;
20
    }
21
22 3
    public function getNonce(): ?string
23
    {
24 3
        return $this->nonce;
25
    }
26
27 3
    public function setState(?string $state): void
28
    {
29 3
        $this->state = $state;
30 3
    }
31
32 3
    public function setNonce(?string $nonce): void
33
    {
34 3
        $this->nonce = $nonce;
35 3
    }
36
37 2
    public static function fromArray(array $array): AuthSessionInterface
38
    {
39 2
        $session = new self();
40 2
        $session->setState($array['state'] ?? null);
41 2
        $session->setNonce($array['nonce'] ?? null);
42
43 2
        return $session;
44
    }
45
46 1
    public function jsonSerialize(): array
47
    {
48 1
        return array_filter([
49 1
            'state' => $this->getState(),
50 1
            'nonce' => $this->getNonce(),
51
        ]);
52
    }
53
}
54