1 | <?php |
||
23 | class InitialAccessToken implements ContainsRecordedMessages, DomainObject |
||
24 | { |
||
25 | use PrivateMessageRecorderCapabilities; |
||
26 | |||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $revoked = false; |
||
31 | |||
32 | /** |
||
33 | * @var InitialAccessTokenId|null |
||
34 | */ |
||
35 | private $initialAccessTokenId = null; |
||
36 | |||
37 | /** |
||
38 | * @var \DateTimeImmutable|null |
||
39 | */ |
||
40 | private $expiresAt = null; |
||
41 | |||
42 | /** |
||
43 | * @var UserAccountId|null |
||
44 | */ |
||
45 | private $userAccountId = null; |
||
46 | |||
47 | /** |
||
48 | * @return InitialAccessToken |
||
49 | */ |
||
50 | public static function createEmpty(): self |
||
54 | |||
55 | /** |
||
56 | * @param InitialAccessTokenId $initialAccessTokenId |
||
57 | * @param UserAccountId $userAccountId |
||
58 | * @param \DateTimeImmutable|null $expiresAt |
||
59 | * |
||
60 | * @return InitialAccessToken |
||
61 | */ |
||
62 | public function create(InitialAccessTokenId $initialAccessTokenId, UserAccountId $userAccountId, ? \DateTimeImmutable $expiresAt): self |
||
74 | |||
75 | /** |
||
76 | * @return InitialAccessTokenId |
||
77 | */ |
||
78 | public function getTokenId(): InitialAccessTokenId |
||
86 | |||
87 | /** |
||
88 | * @return UserAccountId |
||
89 | */ |
||
90 | public function getUserAccountId(): UserAccountId |
||
98 | |||
99 | /** |
||
100 | * @return \DateTimeImmutable|null |
||
101 | */ |
||
102 | public function getExpiresAt(): ? \DateTimeImmutable |
||
106 | |||
107 | /** |
||
108 | * @return bool |
||
109 | */ |
||
110 | public function hasExpired(): bool |
||
114 | |||
115 | /** |
||
116 | * @return bool |
||
117 | */ |
||
118 | public function isRevoked(): bool |
||
122 | |||
123 | /** |
||
124 | * @return InitialAccessToken |
||
125 | */ |
||
126 | public function markAsRevoked(): self |
||
135 | |||
136 | /** |
||
137 | * {@inheritdoc} |
||
138 | */ |
||
139 | public static function getSchema(): string |
||
143 | |||
144 | /** |
||
145 | * {@inheritdoc} |
||
146 | */ |
||
147 | public static function createFromJson(\stdClass $json): DomainObject |
||
162 | |||
163 | /** |
||
164 | * {@inheritdoc} |
||
165 | */ |
||
166 | public function jsonSerialize() |
||
179 | |||
180 | /** |
||
181 | * @param Event $event |
||
182 | * |
||
183 | * @return InitialAccessToken |
||
184 | */ |
||
185 | public function apply(Event $event): self |
||
198 | |||
199 | /** |
||
200 | * @return array |
||
201 | */ |
||
202 | private function getEventMap(): array |
||
209 | |||
210 | /** |
||
211 | * @param InitialAccessTokenEvent\InitialAccessTokenCreatedEvent $event |
||
212 | * |
||
213 | * @return InitialAccessToken |
||
214 | */ |
||
215 | protected function applyInitialAccessTokenCreatedEvent(InitialAccessTokenEvent\InitialAccessTokenCreatedEvent $event): self |
||
224 | |||
225 | /** |
||
226 | * @param InitialAccessTokenEvent\InitialAccessTokenRevokedEvent $event |
||
227 | * |
||
228 | * @return InitialAccessToken |
||
229 | */ |
||
230 | protected function applyInitialAccessTokenRevokedEvent(InitialAccessTokenEvent\InitialAccessTokenRevokedEvent $event): self |
||
237 | } |
||
238 |