You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
expire-email-validation/Entity/ExpiredUser.php

99 lines
1.8 KiB

<?php
namespace vierbergenlars\AuthserverAutoExpireUsersBundle\Entity;
use App\Entity\User;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;
/**
* @Entity()
* @Table(name="vierbergenlars_expire_users")
*/
class ExpiredUser
{
/**
* @OneToOne(targetEntity="App\Entity\User")
* @Id()
*
* @var User
*/
private $user;
/**
* @Column(name="last_login", type="datetime", nullable=true)
*
* @var \DateTime|null
*/
private $lastLogin;
/**
* @Column(name="expired_at", type="datetime", nullable=true)
*
* @var \DateTime|null
*/
private $expiredAt;
public function __construct(User $user)
{
$this->user = $user;
}
/**
*
* @return \App\Entity\User
*/
public function getUser()
{
return $this->user;
}
/**
*
* @return \DateTime|null
*/
public function getLastLogin()
{
return $this->lastLogin;
}
/**
*
* @param \DateTime|null $lastLogin
*/
public function setLastLogin($lastLogin)
{
$this->lastLogin = $lastLogin;
}
/**
*
* @return \DateTime|null
*/
public function getExpiredAt()
{
return $this->expiredAt;
}
/**
*
* @param \DateTime|null $expiredAt
*/
public function setExpiredAt($expiredAt)
{
$this->expiredAt = $expiredAt;
}
/**
* Checks if the user is expired (expiry date is not null and in the past)
*
* @return boolean
*/
public function isExpired()
{
return $this->expiredAt !== null && $this->expiredAt < new \DateTime();
}
}