]> Raphaël G. Git Repositories - airbundle/blobdiff - Entity/Application.php
Version 0.6.1
[airbundle] / Entity / Application.php
index b54b1e2e4cf42a20d5fbab633032d6fd4dc0b3de..23f44bf44bab1f7de0044038a86d4f1c53f41d10 100644 (file)
@@ -1,11 +1,11 @@
 <?php declare(strict_types=1);
 
 /*
- * this file is part of the rapsys packbundle package.
+ * This file is part of the Rapsys AirBundle package.
  *
- * (c) raphaël gertz <symfony@rapsys.eu>
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
  *
- * 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,46 +18,52 @@ use Doctrine\ORM\Event\PreUpdateEventArgs;
  */
 class Application {
        /**
-        * @var integer
+        * Primary key
         */
-       private $id;
+       private ?int $id = null;
 
        /**
-        * @var float
+        * Dance instance
         */
-       private $score;
+       private Dance $dance;
 
        /**
-        * @var \DateTime
+        * Score
         */
-       private $canceled;
+       private ?float $score = null;
 
        /**
-        * @var \DateTime
+        * Cancel datetime
         */
-       private $created;
+       private ?\DateTimeImmutable $canceled = null;
 
        /**
-        * @var \DateTime
+        * Create datetime
         */
-       private $updated;
+       private \DateTimeImmutable $created;
 
        /**
-        * @var \Rapsys\AirBundle\Entity\Session
+        * Update datetime
         */
-       private $session;
+       private \DateTimeImmutable $updated;
 
        /**
-        * @var \Rapsys\AirBundle\Entity\User
+        * Session instance
         */
-       private $user;
+       private $session = null;
+
+       /**
+        * User instance
+        */
+       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');
        }
 
        /**
@@ -65,10 +71,32 @@ class Application {
         *
         * @return integer
         */
-       public function getId(): int {
+       public function getId(): ?int {
                return $this->id;
        }
 
+       /**
+        * Set dance
+        *
+        * @param Dance $dance
+        *
+        * @return Application
+        */
+       public function setDance(Dance $dance): Application {
+               $this->dance = $dance;
+
+               return $this;
+       }
+
+       /**
+        * Get dance
+        *
+        * @return Dance
+        */
+       public function getDance(): Dance {
+               return $this->dance;
+       }
+
        /**
         * Set score
         *
@@ -94,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;
@@ -107,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;
@@ -129,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;
@@ -151,9 +179,9 @@ class Application {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -206,9 +234,9 @@ class Application {
         */
        public function preUpdate(PreUpdateEventArgs $eventArgs) {
                //Check that we have an application instance
-               if (($user = $eventArgs->getEntity()) instanceof Application) {
+               if (($application = $eventArgs->getObject()) instanceof Application) {
                        //Set updated value
-                       $user->setUpdated(new \DateTime('now'));
+                       $application->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 }