id; } public function getPosition(): ?Position { return $this->position; } public function setPosition(Position $position): self { if ($this->position instanceof Position) { throw new \LogicException("The position is already set. You cannot change ". "a position of a membership"); } $this->position = $position; $this->shareHousehold = $position->getShareHousehold(); return $this; } public function getStartDate(): ?\DateTimeImmutable { return $this->startDate; } public function setStartDate(\DateTimeImmutable $startDate): self { $this->startDate = $startDate; return $this; } public function getEndDate(): ?\DateTimeImmutable { return $this->endDate; } public function setEndDate(?\DateTimeImmutable $endDate = null): self { $this->endDate = $endDate; return $this; } public function getComment(): ?string { return $this->comment; } public function setComment(?string $comment): self { $this->comment = $comment; return $this; } /** * @Serializer\Groups({"read"}) */ public function getShareHousehold(): ?bool { return $this->shareHousehold; } public function setShareHousehold(bool $shareHousehold): self { $this->shareHousehold = $shareHousehold; return $this; } public function getPerson(): ?Person { return $this->person; } public function setPerson(?Person $person): self { if ($this->person instanceof Person) { throw new \LogicException("You cannot change person ". "on a membership"); } $this->person = $person; $this->person->addHouseholdParticipation($this); return $this; } public function getHousehold(): ?Household { return $this->household; } public function setHousehold(?Household $household): self { if ($this->household instanceof Household) { throw new \LogicException("You cannot change household ". "on a membership"); } $this->household = $household; return $this; } public function setHolder(bool $holder): self { $this->holder = $holder; return $this; } public function isHolder(): bool { return $this->holder; } public function isCurrent(\DateTimeImmutable $at = null): bool { $at = NULL === $at ? new \DateTimeImmutable('now'): $at; return $this->getStartDate() < $at && ( NULL === $this->getEndDate() || $at < $this->getEndDate() ); } }