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

AuthSession::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 1
b 0
f 0
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