|
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> |
|
|
|
|
|
|
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> |
|
|
|
|
|
|
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
|
|
|
|
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.