uuid = Uuid::v4()->toRfc4122(); $this->type = $type; $this->image = $image; $this->recipientUser = $recipientUser; $this->recipientEmail = $recipientEmail; $this->expiresAt = new \DateTimeImmutable('+' . $ttlDays . ' days'); } public function getUuid(): string { return $this->uuid; } public function getType(): TokenType { return $this->type; } public function getImage(): Image { return $this->image; } public function getRecipientUser(): ?User { return $this->recipientUser; } public function getRecipientEmail(): ?string { return $this->recipientEmail; } public function getExpiresAt(): \DateTimeImmutable { return $this->expiresAt; } public function getUsedAt(): ?\DateTimeImmutable { return $this->usedAt; } public function isValid(): bool { return $this->usedAt === null && $this->expiresAt > new \DateTimeImmutable(); } public function consume(): void { $this->usedAt = new \DateTimeImmutable(); } }