*/ #[ORM\ManyToMany(targetEntity: Candidate::class, inversedBy: 'answersOnCandidate')] private Collection $candidates; /** @var Collection */ #[ORM\OneToMany(targetEntity: GivenAnswer::class, mappedBy: 'answer', orphanRemoval: true)] private Collection $givenAnswers; public function __construct( #[ORM\Column(length: 255)] private string $text, #[ORM\Column] private bool $isRightAnswer = false, ) { $this->candidates = new ArrayCollection(); $this->givenAnswers = new ArrayCollection(); } public function getId(): Uuid { return $this->id; } public function getText(): string { return $this->text; } public function setText(string $text): static { $this->text = $text; return $this; } public function getQuestion(): Question { return $this->question; } public function setQuestion(Question $question): static { $this->question = $question; return $this; } public function isRightAnswer(): ?bool { return $this->isRightAnswer; } public function setRightAnswer(bool $isRightAnswer): static { $this->isRightAnswer = $isRightAnswer; return $this; } /** @return Collection */ public function getCandidates(): Collection { return $this->candidates; } public function addCandidate(Candidate $candidate): static { if (!$this->candidates->contains($candidate)) { $this->candidates->add($candidate); } return $this; } public function removeCandidate(Candidate $candidate): static { $this->candidates->removeElement($candidate); return $this; } /** @return Collection */ public function getGivenAnswers(): Collection { return $this->givenAnswers; } public function addGivenAnswer(GivenAnswer $givenAnswer): static { if (!$this->givenAnswers->contains($givenAnswer)) { $this->givenAnswers->add($givenAnswer); $givenAnswer->setAnswer($this); } return $this; } }