1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace JincorTech\AuthClient\Abstracts; |
4
|
|
|
|
5
|
|
|
use InvalidArgumentException; |
6
|
|
|
use JincorTech\AuthClient\Traits\ValidateParams; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class VerificationResult. |
10
|
|
|
*/ |
11
|
|
|
abstract class VerificationResult |
12
|
|
|
{ |
13
|
|
|
use ValidateParams; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
private $id; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
private $login; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
private $jti; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int |
32
|
|
|
*/ |
33
|
|
|
private $iat; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
private $aud; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* VerificationResult constructor. |
42
|
|
|
* |
43
|
|
|
* @param array $params |
44
|
|
|
* @throws InvalidArgumentException |
45
|
|
|
*/ |
46
|
|
|
public function __construct(array $params) |
47
|
|
|
{ |
48
|
|
|
$this->validateParams($params, ['id', 'login', 'jti', 'iat', 'aud']); |
49
|
|
|
|
50
|
|
|
$this->setId($params['id']); |
51
|
|
|
$this->setLogin($params['login']); |
52
|
|
|
$this->setJti($params['jti']); |
53
|
|
|
$this->setIat($params['iat']); |
|
|
|
|
54
|
|
|
$this->setAud($params['aud']); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public function getId(): string |
61
|
|
|
{ |
62
|
|
|
return $this->id; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
|
|
public function getLogin(): string |
69
|
|
|
{ |
70
|
|
|
return $this->login; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function getJti(): string |
77
|
|
|
{ |
78
|
|
|
return $this->jti; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return int |
83
|
|
|
*/ |
84
|
|
|
public function getIat(): int |
85
|
|
|
{ |
86
|
|
|
return $this->iat; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
|
|
public function getAud(): string |
93
|
|
|
{ |
94
|
|
|
return $this->aud; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param string $id |
99
|
|
|
*/ |
100
|
|
|
private function setId(string $id) |
101
|
|
|
{ |
102
|
|
|
if (empty($id)) { |
103
|
|
|
throw new InvalidArgumentException('Id value can not be empty'); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
$this->id = $id; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param string $login |
111
|
|
|
*/ |
112
|
|
|
private function setLogin(string $login) |
113
|
|
|
{ |
114
|
|
|
if (empty($login)) { |
115
|
|
|
throw new InvalidArgumentException('Login value can not be empty'); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
$this->login = $login; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param string $jti |
123
|
|
|
*/ |
124
|
|
|
private function setJti(string $jti) |
125
|
|
|
{ |
126
|
|
|
if (empty($jti)) { |
127
|
|
|
throw new InvalidArgumentException('Jti value can not be empty'); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
$this->jti = $jti; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param int $iat |
135
|
|
|
*/ |
136
|
|
|
private function setIat(int $iat) |
137
|
|
|
{ |
138
|
|
|
$this->iat = $iat; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @param string $aud |
143
|
|
|
*/ |
144
|
|
|
private function setAud(string $aud) |
145
|
|
|
{ |
146
|
|
|
if (empty($aud)) { |
147
|
|
|
throw new InvalidArgumentException('Aud value can not be empty'); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
$this->aud = $aud; |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
|