*/ #[ORM\ManyToMany(targetEntity: Candidate::class, inversedBy: 'answersOnCandidate')] public private(set) Collection $candidates; /** @var Collection */ #[ORM\OneToMany(targetEntity: GivenAnswer::class, mappedBy: 'answer', orphanRemoval: true)] public private(set) Collection $givenAnswers; public function __construct(string $text, bool $isRightAnswer = false) { parent::__construct($text, $isRightAnswer); $this->candidates = new ArrayCollection(); $this->givenAnswers = new ArrayCollection(); } public function addCandidate(Candidate $candidate): void { if (!$this->candidates->contains($candidate)) { $this->candidates->add($candidate); } } public function removeCandidate(Candidate $candidate): void { $this->candidates->removeElement($candidate); } }