startDate = new \DateTime('now'); $person->getAccompanyingPeriodParticipations()->add($this); } public function getAccompanyingPeriod(): ?AccompanyingPeriod { return $this->accompanyingPeriod; } public function getEndDate(): ?\DateTimeInterface { return $this->endDate; } public function getId(): ?int { return $this->id; } public function getPerson(): ?Person { return $this->person; } public function getStartDate(): ?\DateTimeInterface { return $this->startDate; } public function isOpen(): bool { return null === $this->endDate; } public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self { $this->accompanyingPeriod = $accompanyingPeriod; return $this; } public function setEndDate(?\DateTime $endDate): self { $this->endDate = $endDate; return $this; } public function setPerson(?Person $person): self { $this->person = $person; return $this; } private function checkSameStartEnd() { if ($this->endDate === $this->startDate) { $this->accompanyingPeriod->removeParticipation($this); } } }