<?php
namespace App\Entity;
use App\Repository\ResetPasswordTokenRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ResetPasswordTokenRepository::class)]
class ResetPasswordToken
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 500)]
private $value;
#[ORM\Column(type: 'integer')]
private $expirationDate;
#[ORM\OneToOne(targetEntity: User::class, inversedBy: 'resetPasswordToken', cascade: ['persist'])]
#[ORM\JoinColumn(nullable: false)]
private $User;
public function getId(): ?int
{
return $this->id;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): self
{
$this->value = $value;
return $this;
}
public function getExpirationDate(): ?int
{
return $this->expirationDate;
}
public function setExpirationDate(int $expirationDate): self
{
$this->expirationDate = $expirationDate;
return $this;
}
public function getUser(): ?User
{
return $this->User;
}
public function setUser(?User $User): self
{
$this->User = $User;
return $this;
}
/**
* Return true if expired, false otherwise
*/
public function isItExpired(int $currentEpoch, int $delay): bool
{
if (($this->getExpirationDate() + $delay) >= $currentEpoch) {
return false;
}
return true;
}
}