17
17
*/
18
18
final class ResetPasswordToken
19
19
{
20
- /**
21
- * @var string|null selector + non-hashed verifier token
22
- */
23
- private $ token ;
24
-
25
- /**
26
- * @var \DateTimeInterface
27
- */
28
- private $ expiresAt ;
20
+ private ?string $ token ;
29
21
30
22
/**
31
- * @var int|null timestamp when the token was created
23
+ * @var int expiresAt translator interval
32
24
*/
33
- private $ generatedAt ;
25
+ private int $ transInterval = 0 ;
34
26
35
27
/**
36
- * @var int expiresAt translator interval
28
+ * @param string $token selector + non-hashed verifier token
29
+ * @param int $generatedAt timestamp when the token was created
37
30
*/
38
- private $ transInterval = 0 ;
39
-
40
- public function __construct (string $ token , \DateTimeInterface $ expiresAt , ?int $ generatedAt = null )
41
- {
31
+ public function __construct (
32
+ string $ token ,
33
+ private \DateTimeInterface $ expiresAt ,
34
+ private int $ generatedAt
35
+ ) {
42
36
$ this ->token = $ token ;
43
- $ this ->expiresAt = $ expiresAt ;
44
- $ this ->generatedAt = $ generatedAt ;
45
-
46
- if (null === $ generatedAt ) {
47
- $ this ->triggerDeprecation ();
48
- }
49
37
}
50
38
51
39
/**
@@ -138,10 +126,6 @@ public function getExpirationMessageData(): array
138
126
*/
139
127
public function getExpiresAtIntervalInstance (): \DateInterval
140
128
{
141
- if (null === $ this ->generatedAt ) {
142
- throw new \LogicException (sprintf ('%s initialized without setting the $generatedAt timestamp. ' , self ::class));
143
- }
144
-
145
129
$ createdAtTime = \DateTimeImmutable::createFromFormat ('U ' , (string ) $ this ->generatedAt );
146
130
147
131
if (false === $ createdAtTime ) {
@@ -150,17 +134,4 @@ public function getExpiresAtIntervalInstance(): \DateInterval
150
134
151
135
return $ this ->expiresAt ->diff ($ createdAtTime );
152
136
}
153
-
154
- /**
155
- * @psalm-suppress UndefinedFunction
156
- */
157
- private function triggerDeprecation (): void
158
- {
159
- trigger_deprecation (
160
- 'symfonycasts/reset-password-bundle ' ,
161
- '1.2 ' ,
162
- 'Initializing the %s without setting the "$generatedAt" constructor argument is deprecated. The default "null" will be removed in the future. ' ,
163
- self ::class
164
- );
165
- }
166
137
}
0 commit comments