]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Entity/GoogleCalendar.php
Inherit captcha
[airbundle] / Entity / GoogleCalendar.php
index 70a11749dc4da1f8ac346b1d23244039e3e43e7c..f4ef2cec7cbf6c63065e487d50867c7b92b06009 100644 (file)
@@ -11,8 +11,6 @@
 
 namespace Rapsys\AirBundle\Entity;
 
-use Doctrine\Common\Collections\Collection;
-use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\ORM\Event\PreUpdateEventArgs;
 
 /**
@@ -20,54 +18,30 @@ use Doctrine\ORM\Event\PreUpdateEventArgs;
  */
 class GoogleCalendar {
        /**
-        * @var int
+        * Primary key
         */
-       private ?int $id;
+       private ?int $id = null;
 
        /**
-        * @var string
-        */
-       private $mail;
-
-       /**
-        * @var string
-        */
-       private $summary;
-
-       /**
-        * @var \DateTime
-        */
-       private ?\DateTime $synchronized;
-
-       /**
-        * @var \DateTime
+        * Create datetime
         */
        private \DateTime $created;
 
        /**
-        * @var \DateTime
+        * Update datetime
         */
        private \DateTime $updated;
 
-       /**
-        * @var \Rapsys\AirBundle\Entity\GoogleToken
-        */
-       private GoogleToken $googleToken;
-
        /**
         * Constructor
         *
-        * @param \Rapsys\AirBundle\Entity\GoogleToken $googleToken The google token
+        * @param GoogleToken $googleToken The google token
         * @param string $mail The google calendar id
         * @param string $summary The google calendar summary
-        * @param ?\DateTime $synchronized The google calendar last synchronization
+        * @param \DateTime $synchronized The google calendar last synchronization
         */
-       public function __construct(GoogleToken $googleToken, string $mail, string $summary, ?\DateTime $synchronized = null) {
+       public function __construct(private GoogleToken $googleToken, private string $mail, private string $summary, private \DateTime $synchronized = new \DateTime('now')) {
                //Set defaults
-               $this->googleToken = $googleToken;
-               $this->mail = $mail;
-               $this->summary = $summary;
-               $this->synchronized = $synchronized;
                $this->created = new \DateTime('now');
                $this->updated = new \DateTime('now');
        }
@@ -126,11 +100,11 @@ class GoogleCalendar {
        /**
         * Set synchronized
         *
-        * @param ?\DateTime $synchronized
+        * @param \DateTime $synchronized
         *
         * @return GoogleCalendar
         */
-       public function setSynchronized(?\DateTime $synchronized = null): GoogleCalendar {
+       public function setSynchronized(\DateTime $synchronized): GoogleCalendar {
                $this->synchronized = $synchronized;
 
                return $this;
@@ -139,9 +113,9 @@ class GoogleCalendar {
        /**
         * Get synchronized
         *
-        * @return ?\DateTime
+        * @return \DateTime
         */
-       public function getSynchronized(): ?\DateTime {
+       public function getSynchronized(): \DateTime {
                return $this->synchronized;
        }
 
@@ -216,7 +190,7 @@ class GoogleCalendar {
         */
        public function preUpdate(PreUpdateEventArgs $eventArgs): ?GoogleCalendar {
                //Check that we have an snippet instance
-               if (($entity = $eventArgs->getEntity()) instanceof GoogleCalendar) {
+               if (($entity = $eventArgs->getObject()) instanceof GoogleCalendar) {
                        //Set updated value
                        return $entity->setUpdated(new \DateTime('now'));
                }