mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -13,8 +13,6 @@ namespace Chill\TaskBundle\Entity;
|
||||
|
||||
use Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -27,6 +25,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
* @ORM\Table(
|
||||
* name="chill_task.single_task",
|
||||
* indexes={
|
||||
*
|
||||
* @ORM\Index(
|
||||
* name="by_type",
|
||||
* columns={ "type" }
|
||||
@@ -41,23 +40,27 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\TaskBundle\Repository\SingleTaskRepository")
|
||||
*/
|
||||
class SingleTask extends AbstractTask
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="end_date", type="date", nullable=true)
|
||||
*
|
||||
* @Assert\Date
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?\DateTime $endDate = null;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
@@ -71,16 +74,16 @@ class SingleTask extends AbstractTask
|
||||
private ?\Chill\TaskBundle\Entity\RecurringTask $recurringTask = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\Column(name="start_date", type="date", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*
|
||||
* @Assert\Date
|
||||
*
|
||||
* @Assert\Expression(
|
||||
* "value === null or this.getEndDate() === null or value < this.getEndDate()",
|
||||
* message="The start date must be before the end date"
|
||||
* )
|
||||
*
|
||||
* @Assert\Expression(
|
||||
* "value === null or this.getWarningDate() === null or this.getWarningDate() > this.getStartDate()",
|
||||
* message="The start date must be before warning date"
|
||||
@@ -90,6 +93,7 @@ class SingleTask extends AbstractTask
|
||||
|
||||
/**
|
||||
* @var Collection<SingleTaskPlaceEvent>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="\Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent",
|
||||
* mappedBy="task",
|
||||
@@ -99,10 +103,11 @@ class SingleTask extends AbstractTask
|
||||
private Collection $taskPlaceEvents;
|
||||
|
||||
/**
|
||||
* @var DateInterval
|
||||
* and this.getEndDate() === null
|
||||
* @var \DateInterval
|
||||
* and this.getEndDate() === null
|
||||
*
|
||||
* @ORM\Column(name="warning_interval", type="dateinterval", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*
|
||||
* @Assert\Expression(
|
||||
@@ -110,7 +115,7 @@ class SingleTask extends AbstractTask
|
||||
* message="An end date is required if a warning interval is set"
|
||||
* )
|
||||
*/
|
||||
private $warningInterval;
|
||||
private null|\DateInterval $warningInterval = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -119,10 +124,8 @@ class SingleTask extends AbstractTask
|
||||
|
||||
/**
|
||||
* Get endDate.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getEndDate()
|
||||
public function getEndDate(): null|\DateTime
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
@@ -145,7 +148,7 @@ class SingleTask extends AbstractTask
|
||||
/**
|
||||
* Get startDate.
|
||||
*
|
||||
* @return DateTime
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getStartDate()
|
||||
{
|
||||
@@ -163,29 +166,28 @@ class SingleTask extends AbstractTask
|
||||
*
|
||||
* Return null if warningDate or endDate is null
|
||||
*
|
||||
* @return DateTimeImmutable
|
||||
* @return \DateTimeImmutable
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
public function getWarningDate()
|
||||
{
|
||||
if ($this->getWarningInterval() === null) {
|
||||
if (null === $this->getWarningInterval()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->getEndDate() === null) {
|
||||
if (null === $this->getEndDate()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return DateTimeImmutable::createFromMutable($this->getEndDate())
|
||||
return \DateTimeImmutable::createFromMutable($this->getEndDate())
|
||||
->sub($this->getWarningInterval());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get warningInterval.
|
||||
*
|
||||
* @return DateInterval
|
||||
*/
|
||||
public function getWarningInterval()
|
||||
public function getWarningInterval(): null|\DateInterval
|
||||
{
|
||||
return $this->warningInterval;
|
||||
}
|
||||
@@ -193,7 +195,7 @@ class SingleTask extends AbstractTask
|
||||
/**
|
||||
* Set endDate.
|
||||
*
|
||||
* @param DateTime $endDate
|
||||
* @param \DateTime $endDate
|
||||
*
|
||||
* @return SingleTask
|
||||
*/
|
||||
@@ -212,7 +214,7 @@ class SingleTask extends AbstractTask
|
||||
/**
|
||||
* Set startDate.
|
||||
*
|
||||
* @param DateTime $startDate
|
||||
* @param \DateTime $startDate
|
||||
*
|
||||
* @return SingleTask
|
||||
*/
|
||||
@@ -233,11 +235,9 @@ class SingleTask extends AbstractTask
|
||||
/**
|
||||
* Set warningInterval.
|
||||
*
|
||||
* @param string $warningInterval
|
||||
*
|
||||
* @return SingleTask
|
||||
*/
|
||||
public function setWarningInterval($warningInterval)
|
||||
public function setWarningInterval(null|\DateInterval $warningInterval)
|
||||
{
|
||||
$this->warningInterval = $warningInterval;
|
||||
|
||||
|
Reference in New Issue
Block a user