<?phpnamespace App\Entity;use App\Repository\QuestionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: QuestionRepository::class)]class Question{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $content = null; #[ORM\Column(length: 50)] private ?string $type = null; #[ORM\Column] private ?int $position = null; #[ORM\Column(type: 'boolean')] private bool $required = true; #[ORM\ManyToOne(inversedBy: 'questions')] #[ORM\JoinColumn(nullable: false)] private ?Survey $survey = null; #[ORM\OneToMany(mappedBy: 'question', targetEntity: QuestionOption::class, orphanRemoval: true, cascade: ['persist'])] private Collection $options; #[ORM\OneToMany(mappedBy: 'question', targetEntity: QuestionResponse::class, orphanRemoval: true)] private Collection $responses; #[ORM\Column(type: 'json', nullable: true)] private ?array $conditions = null; public function __construct() { $this->options = new ArrayCollection(); $this->responses = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getContent(): ?string { return $this->content; } public function setContent(string $content): self { $this->content = $content; return $this; } public function getType(): ?string { return $this->type; } public function setType(string $type): self { $this->type = $type; return $this; } public function getPosition(): ?int { return $this->position; } public function setPosition(int $position): self { $this->position = $position; return $this; } public function isRequired(): bool { return $this->required; } public function setRequired(bool $required): self { $this->required = $required; return $this; } public function getSurvey(): ?Survey { return $this->survey; } public function setSurvey(?Survey $survey): self { $this->survey = $survey; return $this; } /** * @return Collection<int, QuestionOption> */ public function getOptions(): Collection { return $this->options; } public function addOption(QuestionOption $option): self { if (!$this->options->contains($option)) { $this->options->add($option); $option->setQuestion($this); } return $this; } public function removeOption(QuestionOption $option): self { if ($this->options->removeElement($option)) { if ($option->getQuestion() === $this) { $option->setQuestion(null); } } return $this; } /** * @return Collection<int, QuestionResponse> */ public function getResponses(): Collection { return $this->responses; } public function addResponse(QuestionResponse $response): self { if (!$this->responses->contains($response)) { $this->responses->add($response); $response->setQuestion($this); } return $this; } public function removeResponse(QuestionResponse $response): self { if ($this->responses->removeElement($response)) { if ($response->getQuestion() === $this) { $response->setQuestion(null); } } return $this; } public function getConditions(): ?array { return $this->conditions; } public function setConditions(?array $conditions): self { $this->conditions = $conditions; return $this; }}