namespace Rapsys\AirBundle\Entity;
-use Doctrine\Common\Collections\Collection;
-use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Event\PreUpdateEventArgs;
/**
*/
class GoogleCalendar {
/**
- * @var int
+ * Primary key
*/
- private ?int $id;
+ private ?int $id = null;
/**
- * @var string
+ * Create datetime
*/
- private $mail;
+ private \DateTimeImmutable $created;
/**
- * @var string
+ * Update datetime
*/
- private $summary;
-
- /**
- * @var \DateTime
- */
- private \DateTime $synchronized;
-
- /**
- * @var \DateTime
- */
- private \DateTime $created;
-
- /**
- * @var \DateTime
- */
- private \DateTime $updated;
-
- /**
- * @var \Rapsys\AirBundle\Entity\GoogleToken
- */
- private GoogleToken $googleToken;
+ private \DateTimeImmutable $updated;
/**
* 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 \DateTimeImmutable $synchronized The google calendar last synchronization
*/
- public function __construct(GoogleToken $googleToken, string $mail, string $summary, \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->googleToken = $googleToken;
- $this->mail = $mail;
- $this->summary = $summary;
- $this->synchronized = $synchronized;
- $this->created = new \DateTime('now');
- $this->updated = new \DateTime('now');
+ $this->created = new \DateTimeImmutable('now');
+ $this->updated = new \DateTimeImmutable('now');
}
/**
/**
* 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;
/**
* 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;
/**
* 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;
/**
* Get updated
*
- * @return \DateTime
+ * @return \DateTimeImmutable
*/
- public function getUpdated(): \DateTime {
+ public function getUpdated(): \DateTimeImmutable {
return $this->updated;
}
//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'));
}
}
}