<?phpnamespace App\Entity\Channel\PositioningTest\Attempt;use App\Entity\Channel\PositioningTest\Question;use App\Entity\Channel\PositioningTest\QuestionAnswer;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use DrosalysWeb\ObjectExtensions\Blame\Model\BlameInterface;use DrosalysWeb\ObjectExtensions\Blame\Model\BlameTrait;use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampInterface;use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;#[ ORM\Entity(), ORM\Table(name: 'channel_positioning_test_attempt_answers'),]class Answer implements TimestampInterface, BlameInterface{ use TimestampTrait; use BlameTrait; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private ?int $id = null; #[ORM\Column(type: 'boolean')] private bool $valid = false; #[ORM\ManyToOne(targetEntity: AttemptBlock::class, inversedBy: 'answers')] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] private ?AttemptBlock $attemptBlock = null; #[ORM\ManyToOne(targetEntity: Question::class)] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] private ?Question $question = null; #[ORM\ManyToMany(targetEntity: QuestionAnswer::class)] #[ORM\JoinTable('channel_positioning_test_attempt_answer_selected_answers')] private ?Collection $selectedAnswers = null; public function __construct() { $this->selectedAnswers = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function isValid(): bool { return $this->valid; } public function setValid(bool $valid): static { $this->valid = $valid; return $this; } public function getAttemptBlock(): ?AttemptBlock { return $this->attemptBlock; } public function setAttemptBlock(?AttemptBlock $attemptBlock): static { $this->attemptBlock = $attemptBlock; return $this; } public function getQuestion(): ?Question { return $this->question; } public function setQuestion(?Question $question): static { $this->question = $question; return $this; } public function getSelectedAnswers(): ?Collection { return $this->selectedAnswers; } public function addSelectedAnswer(QuestionAnswer $answer): self { if (!$this->selectedAnswers->contains($answer)) { $this->selectedAnswers[] = $answer; } return $this; } public function removeSelectedAnswer(QuestionAnswer $answer): self { if ($this->selectedAnswers->contains($answer)) { $this->selectedAnswers->removeElement($answer); } return $this; }}