]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Entity/GoogleCalendar.php
Replace deprecated DateTime by DateTimeImmutable
[airbundle] / Entity / GoogleCalendar.php
index f4ef2cec7cbf6c63065e487d50867c7b92b06009..edf124c7393bd5db8a711fb3162c9232ebb3974a 100644 (file)
@@ -25,12 +25,12 @@ class GoogleCalendar {
        /**
         * Create datetime
         */
-       private \DateTime $created;
+       private \DateTimeImmutable $created;
 
        /**
         * Update datetime
         */
-       private \DateTime $updated;
+       private \DateTimeImmutable $updated;
 
        /**
         * Constructor
@@ -38,12 +38,12 @@ class GoogleCalendar {
         * @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 \DateTimeImmutable $synchronized The google calendar last synchronization
         */
-       public function __construct(private GoogleToken $googleToken, private string $mail, private string $summary, private \DateTime $synchronized = new \DateTime('now')) {
+       public function __construct(private GoogleToken $googleToken, private string $mail, private string $summary, private \DateTimeImmutable $synchronized = new \DateTime('now')) {
                //Set defaults
-               $this->created = new \DateTime('now');
-               $this->updated = new \DateTime('now');
+               $this->created = new \DateTimeImmutable('now');
+               $this->updated = new \DateTimeImmutable('now');
        }
 
        /**
@@ -100,11 +100,11 @@ class GoogleCalendar {
        /**
         * Set synchronized
         *
-        * @param \DateTime $synchronized
+        * @param \DateTimeImmutable $synchronized
         *
         * @return GoogleCalendar
         */
-       public function setSynchronized(\DateTime $synchronized): GoogleCalendar {
+       public function setSynchronized(\DateTimeImmutable $synchronized): GoogleCalendar {
                $this->synchronized = $synchronized;
 
                return $this;
@@ -113,20 +113,20 @@ class GoogleCalendar {
        /**
         * Get synchronized
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getSynchronized(): \DateTime {
+       public function getSynchronized(): \DateTimeImmutable {
                return $this->synchronized;
        }
 
        /**
         * Set created
         *
-        * @param \DateTime $created
+        * @param \DateTimeImmutable $created
         *
         * @return GoogleCalendar
         */
-       public function setCreated(\DateTime $created): GoogleCalendar {
+       public function setCreated(\DateTimeImmutable $created): GoogleCalendar {
                $this->created = $created;
 
                return $this;
@@ -135,20 +135,20 @@ class GoogleCalendar {
        /**
         * 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 GoogleCalendar
         */
-       public function setUpdated(\DateTime $updated): GoogleCalendar {
+       public function setUpdated(\DateTimeImmutable $updated): GoogleCalendar {
                $this->updated = $updated;
 
                return $this;
@@ -157,9 +157,9 @@ class GoogleCalendar {
        /**
         * Get updated
         *
-        * @return \DateTime
+        * @return \DateTimeImmutable
         */
-       public function getUpdated(): \DateTime {
+       public function getUpdated(): \DateTimeImmutable {
                return $this->updated;
        }
 
@@ -192,7 +192,7 @@ class GoogleCalendar {
                //Check that we have an snippet instance
                if (($entity = $eventArgs->getObject()) instanceof GoogleCalendar) {
                        //Set updated value
-                       return $entity->setUpdated(new \DateTime('now'));
+                       return $entity->setUpdated(new \DateTimeImmutable('now'));
                }
        }
 }