src/Entity/Common/DateTimeInterval.php line 9
<?php
namespace App\Entity\Common;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Embeddable]
class DateTimeInterval implements DateTimeIntervalInterface
{
/**
* @var DateTime|null
*/
#[ORM\Column(type: 'datetime', nullable: true)]
private $from;
/**
* @var DateTime|null
*/
#[ORM\Column(type: 'datetime', nullable: true)]
private $to;
/**
* @return DateTime|null
*/
public function getFrom(): ?DateTime
{
return $this->from;
}
/**
* @param DateTime|null $from
*/
public function setFrom(?DateTime $from): void
{
$this->from = $from;
}
/**
* @return DateTime|null
*/
public function getTo(): ?DateTime
{
return $this->to;
}
/**
* @param DateTime|null $to
*/
public function setTo(?DateTime $to): void
{
$this->to = $to;
}
public function isEnded(): bool
{
if (is_null($this->to)) {
return false;
}
$now = new \DateTime();
if ($this->to <= $now) {
return true;
}
return false;
}
}