1717 */
1818final class ResetPasswordToken
1919{
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 ;
2921
3022 /**
31- * @var int|null timestamp when the token was created
23+ * @var int expiresAt translator interval
3224 */
33- private $ generatedAt ;
25+ private int $ transInterval = 0 ;
3426
3527 /**
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
3730 */
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+ ) {
4236 $ this ->token = $ token ;
43- $ this ->expiresAt = $ expiresAt ;
44- $ this ->generatedAt = $ generatedAt ;
45-
46- if (null === $ generatedAt ) {
47- $ this ->triggerDeprecation ();
48- }
4937 }
5038
5139 /**
@@ -138,10 +126,6 @@ public function getExpirationMessageData(): array
138126 */
139127 public function getExpiresAtIntervalInstance (): \DateInterval
140128 {
141- if (null === $ this ->generatedAt ) {
142- throw new \LogicException (sprintf ('%s initialized without setting the $generatedAt timestamp. ' , self ::class));
143- }
144-
145129 $ createdAtTime = \DateTimeImmutable::createFromFormat ('U ' , (string ) $ this ->generatedAt );
146130
147131 if (false === $ createdAtTime ) {
@@ -150,17 +134,4 @@ public function getExpiresAtIntervalInstance(): \DateInterval
150134
151135 return $ this ->expiresAt ->diff ($ createdAtTime );
152136 }
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- }
166137}
0 commit comments