user = $user; $this->token = $token; } public function getId(): ?int { return $this->id; } public function getUser(): User { return $this->user; } public function setName(?string $name): void { $this->name = $name; } public function getName(): ?string { return $this->name; } public function setLastUsage(\DateTimeImmutable $lastUsage): void { $this->lastUsage = $lastUsage; } public function getLastUsage(): ?\DateTimeImmutable { return $this->lastUsage; } public function getToken(): string { return $this->token; } public function getExpiresAt(): ?\DateTimeImmutable { return $this->expiresAt; } public function setExpiresAt(?\DateTimeImmutable $expiresAt): void { $this->expiresAt = $expiresAt; } public function isValid(): bool { return $this->expiresAt === null || $this->expiresAt > new \DateTimeImmutable(); } public function __clone() { if ($this->id) { $this->id = null; } } }