dateUpdate = new \DateTime(); // $this->autoDateUpdate(); } /** * @return \DateTime */ public function getDateUpdate(): \DateTime { return $this->dateUpdate; } /** * @throws \Exception */ private function autoDateUpdate(): void { if ($this->getDateUpdate() == null) $this->dateUpdate = new \DateTime(); $this->dateUpdate = new \DateTime(); } public function setDateUpdate(?\DateTimeInterface $dateUpdate): self { $this->dateUpdate = $dateUpdate; return $this; } }