X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/6d87d1dbad7e333cd41b57c641515ae05a7653f3..362c4f90cf3eb7731bfdfc23cb9652db0430c058:/Entity/Application.php diff --git a/Entity/Application.php b/Entity/Application.php index 48e6992..23f44bf 100644 --- a/Entity/Application.php +++ b/Entity/Application.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. */ @@ -18,51 +18,52 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class Application { /** - * @var integer + * Primary key */ - private $id; + private ?int $id = null; /** - * @var Dance + * Dance instance */ - private $dance; + private Dance $dance; /** - * @var float + * Score */ - private $score; + private ?float $score = null; /** - * @var \DateTime + * Cancel datetime */ - private $canceled; + private ?\DateTimeImmutable $canceled = null; /** - * @var \DateTime + * Create datetime */ - private $created; + private \DateTimeImmutable $created; /** - * @var \DateTime + * Update datetime */ - private $updated; + private \DateTimeImmutable $updated; /** - * @var \Rapsys\AirBundle\Entity\Session + * Session instance */ - private $session; + private $session = null; /** - * @var \Rapsys\AirBundle\Entity\User + * User instance */ - private $user; + private $user = null; /** * Constructor */ public function __construct() { - $this->session = null; - $this->user = null; + //Set defaults + $this->created = new \DateTimeImmutable('now'); + $this->updated = new \DateTimeImmutable('now'); } /** @@ -70,7 +71,7 @@ class Application { * * @return integer */ - public function getId(): int { + public function getId(): ?int { return $this->id; } @@ -79,9 +80,9 @@ class Application { * * @param Dance $dance * - * @return Session + * @return Application */ - public function setDance(Dance $dance): Session { + public function setDance(Dance $dance): Application { $this->dance = $dance; return $this; @@ -121,11 +122,11 @@ class Application { /** * Set canceled * - * @param \DateTime $canceled + * @param \DateTimeImmutable $canceled * * @return Application */ - public function setCanceled(?\DateTime $canceled): Application { + public function setCanceled(?\DateTimeImmutable $canceled): Application { $this->canceled = $canceled; return $this; @@ -134,20 +135,20 @@ class Application { /** * Get canceled * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getCanceled(): ?\DateTime { + public function getCanceled(): ?\DateTimeImmutable { return $this->canceled; } /** * Set created * - * @param \DateTime $created + * @param \DateTimeImmutable $created * * @return Application */ - public function setCreated(\DateTime $created): Application { + public function setCreated(\DateTimeImmutable $created): Application { $this->created = $created; return $this; @@ -156,20 +157,20 @@ class Application { /** * 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 Application */ - public function setUpdated(\DateTime $updated): Application { + public function setUpdated(\DateTimeImmutable $updated): Application { $this->updated = $updated; return $this; @@ -178,9 +179,9 @@ class Application { /** * Get updated * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getUpdated(): \DateTime { + public function getUpdated(): \DateTimeImmutable { return $this->updated; } @@ -233,9 +234,9 @@ class Application { */ public function preUpdate(PreUpdateEventArgs $eventArgs) { //Check that we have an application instance - if (($application = $eventArgs->getEntity()) instanceof Application) { + if (($application = $eventArgs->getObject()) instanceof Application) { //Set updated value - $application->setUpdated(new \DateTime('now')); + $application->setUpdated(new \DateTimeImmutable('now')); } } }