accompanyingPeriod; } public function getComment(): ?string { return $this->comment; } public function getId(): ?int { return $this->id; } public function getPerson(): ?Person { return $this->person; } /** * @return Person|ThirdParty * @Groups({"read"}) */ public function getResource() { return $this->person ?? $this->thirdParty; } public function getThirdParty(): ?ThirdParty { return $this->thirdParty; } public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self { $this->accompanyingPeriod = $accompanyingPeriod; return $this; } public function setComment(?string $comment = null): self { $this->comment = (string) $comment; return $this; } /** * @param $resource Person|ThirdParty */ public function setResource($resource): self { if ($resource instanceof ThirdParty) { $this->setThirdParty($resource); $this->setPerson(null); } elseif ($resource instanceof Person) { $this->setPerson($resource); $this->setThirdParty(null); } elseif (null === $resource) { $this->setPerson(null); $this->setThirdParty(null); } else { throw new UnexpectedValueException(sprintf( 'the resource ' . 'should be an instance of %s or %s', Person::class, ThirdParty::class )); } return $this; } private function setPerson(?Person $person): self { $this->person = $person; return $this; } private function setThirdParty(?ThirdParty $thirdParty): self { $this->thirdParty = $thirdParty; return $this; } }