|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AbterPhp\Admin\Domain\Entities; |
|
6
|
|
|
|
|
7
|
|
|
use AbterPhp\Framework\Domain\Entities\IStringerEntity; |
|
8
|
|
|
use DateTimeImmutable; |
|
9
|
|
|
|
|
10
|
|
|
class Token implements IStringerEntity |
|
11
|
|
|
{ |
|
12
|
|
|
/** @var string */ |
|
13
|
|
|
protected $id; |
|
14
|
|
|
|
|
15
|
|
|
/** @var string */ |
|
16
|
|
|
protected $apiClientId; |
|
17
|
|
|
|
|
18
|
|
|
/** @var DateTimeImmutable|null */ |
|
19
|
|
|
protected $expiresAt; |
|
20
|
|
|
|
|
21
|
|
|
/** @var DateTimeImmutable|null */ |
|
22
|
|
|
protected $revokedAt; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string[] */ |
|
25
|
|
|
protected $adminResources; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Token constructor. |
|
29
|
|
|
* |
|
30
|
|
|
* @param string $id |
|
31
|
|
|
* @param string $apiClientId |
|
32
|
|
|
* @param DateTimeImmutable|null $expiresAt |
|
33
|
|
|
* @param DateTimeImmutable|null $revokedAt |
|
34
|
|
|
* @param string[] $adminResources |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct( |
|
37
|
|
|
string $id, |
|
38
|
|
|
string $apiClientId, |
|
39
|
|
|
?DateTimeImmutable $expiresAt, |
|
40
|
|
|
?DateTimeImmutable $revokedAt, |
|
41
|
|
|
array $adminResources = [] |
|
42
|
|
|
) { |
|
43
|
|
|
$this->id = $id; |
|
44
|
|
|
$this->apiClientId = $apiClientId; |
|
45
|
|
|
$this->expiresAt = $expiresAt; |
|
46
|
|
|
$this->revokedAt = $revokedAt; |
|
47
|
|
|
$this->adminResources = $adminResources; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return string |
|
52
|
|
|
*/ |
|
53
|
|
|
public function getId() |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->id; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param string $id |
|
60
|
|
|
*/ |
|
61
|
|
|
public function setId($id) |
|
62
|
|
|
{ |
|
63
|
|
|
$this->id = $id; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return string |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getApiClientId(): string |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->apiClientId; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param string $apiClientId |
|
76
|
|
|
*/ |
|
77
|
|
|
public function setApiClientId(string $apiClientId): Token |
|
78
|
|
|
{ |
|
79
|
|
|
$this->apiClientId = $apiClientId; |
|
80
|
|
|
|
|
81
|
|
|
return $this; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return DateTimeImmutable|null |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getExpiresAt(): ?DateTimeImmutable |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->expiresAt; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param DateTimeImmutable|null $expiresAt |
|
94
|
|
|
*/ |
|
95
|
|
|
public function setExpiresAt(?DateTimeImmutable $expiresAt): Token |
|
96
|
|
|
{ |
|
97
|
|
|
$this->expiresAt = $expiresAt; |
|
98
|
|
|
|
|
99
|
|
|
return $this; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return DateTimeImmutable|null |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getRevokedAt(): ?DateTimeImmutable |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->revokedAt; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @param DateTimeImmutable|null $revokedAt |
|
112
|
|
|
*/ |
|
113
|
|
|
public function setRevokedAt(?DateTimeImmutable $revokedAt): Token |
|
114
|
|
|
{ |
|
115
|
|
|
$this->revokedAt = $revokedAt; |
|
116
|
|
|
|
|
117
|
|
|
return $this; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @return string[] |
|
122
|
|
|
*/ |
|
123
|
|
|
public function getAdminResources(): array |
|
124
|
|
|
{ |
|
125
|
|
|
return $this->adminResources; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* @param string[] $adminResources |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setAdminResources(array $adminResources): void |
|
132
|
|
|
{ |
|
133
|
|
|
$this->adminResources = $adminResources; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @return string |
|
138
|
|
|
*/ |
|
139
|
|
|
public function __toString(): string |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->getUsername(); |
|
|
|
|
|
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.