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

AuthSession   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 55.56%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 42
ccs 10
cts 18
cp 0.5556
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setState() 0 3 1
A getNonce() 0 3 1
A fromArray() 0 7 1
A setNonce() 0 3 1
A getState() 0 3 1
A jsonSerialize() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\OpenIdClient\Model;
6
7
class AuthSession implements AuthSessionInterface
8
{
9
    /** @var null|string */
10
    private $state;
11
12
    /** @var null|string */
13
    private $nonce;
14
15 1
    public function getState(): ?string
16
    {
17 1
        return $this->state;
18
    }
19
20 1
    public function getNonce(): ?string
21
    {
22 1
        return $this->nonce;
23
    }
24
25 1
    public function setState(?string $state): void
26
    {
27 1
        $this->state = $state;
28 1
    }
29
30 1
    public function setNonce(?string $nonce): void
31
    {
32 1
        $this->nonce = $nonce;
33 1
    }
34
35
    public static function fromArray(array $array): AuthSessionInterface
36
    {
37
        $session = new self();
38
        $session->setState($array['state'] ?? null);
39
        $session->setNonce($array['nonce'] ?? null);
40
41
        return $session;
42
    }
43
44
    public function jsonSerialize()
45
    {
46
        return [
47
            'state' => $this->getState(),
48
            'nonce' => $this->getNonce(),
49
        ];
50
    }
51
}
52