X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/d3c8ab5a395adc36ec3095e7effb6f0db195887b..refs/heads/master:/Entity/Session.php diff --git a/Entity/Session.php b/Entity/Session.php index 1cba677..8d89769 100644 --- a/Entity/Session.php +++ b/Entity/Session.php @@ -1,11 +1,11 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -29,22 +29,22 @@ class Session { /** * Begin time */ - private ?\DateTime $begin = null; + private ?\DateTimeImmutable $begin = null; /** * Computed start datetime */ - private ?\DateTime $start = null; + private ?\DateTimeImmutable $start = null; /** * Length time */ - private ?\DateTime $length = null; + private ?\DateTimeImmutable $length = null; /** * Computed stop datetime */ - private ?\DateTime $stop = null; + private ?\DateTimeImmutable $stop = null; /** * Premium @@ -94,17 +94,17 @@ class Session { /** * Lock datetime */ - private ?\DateTime $locked = null; + private ?\DateTimeImmutable $locked = null; /** - * Creation datetime + * Create datetime */ - private \DateTime $created; + private \DateTimeImmutable $created; /** * Update datetime */ - private \DateTime $updated; + private \DateTimeImmutable $updated; /** * Application instance @@ -119,10 +119,12 @@ class Session { /** * Constructor */ - public function __construct(private \DateTime $date, private Location $location, private Slot $slot) { + public function __construct(private \DateTimeImmutable $date, private Location $location, private Slot $slot) { //Set defaults - $this->created = new \DateTime('now'); - $this->updated = new \DateTime('now'); + $this->created = new \DateTimeImmutable('now'); + $this->updated = new \DateTimeImmutable('now'); + + //Set collections $this->applications = new ArrayCollection(); } @@ -138,11 +140,11 @@ class Session { /** * Set date * - * @param \DateTime $date + * @param \DateTimeImmutable $date * * @return Session */ - public function setDate(\DateTime $date): Session { + public function setDate(\DateTimeImmutable $date): Session { $this->date = $date; return $this; @@ -151,20 +153,20 @@ class Session { /** * Get date * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getDate(): \DateTime { + public function getDate(): \DateTimeImmutable { return $this->date; } /** * Set begin * - * @param \DateTime $begin + * @param \DateTimeImmutable $begin * * @return Session */ - public function setBegin(?\DateTime $begin): Session { + public function setBegin(?\DateTimeImmutable $begin): Session { $this->begin = $begin; return $this; @@ -173,18 +175,18 @@ class Session { /** * Get begin * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getBegin(): ?\DateTime { + public function getBegin(): ?\DateTimeImmutable { return $this->begin; } /** * Get start * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getStart(): \DateTime { + public function getStart(): \DateTimeImmutable { //With start if ($this->start !== null) { return $this->start; @@ -213,11 +215,11 @@ class Session { /** * Set length * - * @param \DateTime $length + * @param \DateTimeImmutable $length * * @return Session */ - public function setLength(?\DateTime $length): Session { + public function setLength(?\DateTimeImmutable $length): Session { $this->length = $length; return $this; @@ -226,18 +228,18 @@ class Session { /** * Get length * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getLength(): ?\DateTime { + public function getLength(): ?\DateTimeImmutable { return $this->length; } /** * Get stop * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getStop(): \DateTime { + public function getStop(): \DateTimeImmutable { //Check start if ($this->stop !== null) { return $this->stop; @@ -457,11 +459,11 @@ class Session { /** * Set locked * - * @param \DateTime $locked + * @param \DateTimeImmutable $locked * * @return Session */ - public function setLocked(?\DateTime $locked): Session { + public function setLocked(?\DateTimeImmutable $locked): Session { $this->locked = $locked; return $this; @@ -470,20 +472,20 @@ class Session { /** * Get locked * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getLocked(): ?\DateTime { + public function getLocked(): ?\DateTimeImmutable { return $this->locked; } /** * Set created * - * @param \DateTime $created + * @param \DateTimeImmutable $created * * @return Session */ - public function setCreated(\DateTime $created): Session { + public function setCreated(\DateTimeImmutable $created): Session { $this->created = $created; return $this; @@ -492,20 +494,20 @@ class Session { /** * Get created * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getCreated(): \DateTime { + public function getCreated(): \DateTimeImmutable { return $this->created; } /** * Set updated * - * @param \DateTime $updated + * @param \DateTimeImmutable $updated * * @return Session */ - public function setUpdated(\DateTime $updated): Session { + public function setUpdated(\DateTimeImmutable $updated): Session { $this->updated = $updated; return $this; @@ -514,9 +516,9 @@ class Session { /** * Get updated * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getUpdated(): \DateTime { + public function getUpdated(): \DateTimeImmutable { return $this->updated; } @@ -624,7 +626,7 @@ class Session { //Check that we have a session instance if (($session = $eventArgs->getObject()) instanceof Session) { //Set updated value - $session->setUpdated(new \DateTime('now')); + $session->setUpdated(new \DateTimeImmutable('now')); } }