src/Entity/PollQuestion.php line 13
<?phpdeclare(strict_types=1);namespace App\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use App\Repository\PollQuestionRepository;#[ORM\Entity(repositoryClass: PollQuestionRepository::class)]#[ORM\Table(name: 'poll_questions')]class PollQuestion{public const TYPE_NUMBER = 'number';public const TYPE_TEXT = 'text';public const TYPE_OPTION = 'option';public const TYPES = [self::TYPE_NUMBER,self::TYPE_TEXT,self::TYPE_OPTION,];public const DEFAULT_EVALUATION_PROMPT_TEMPLATE = "From the following {{OPTIONS}}, return the number of the option that is closest to the answer given by the user if the question was: {{QUESTION}}. If the user's answer is not close to any of the options -1 should be your response";#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column(type: 'integer')]private ?int $id = null;#[ORM\Column(type: 'string', length: 255)]private ?string $question = null;#[ORM\Column(type: 'string', length: 20)]private ?string $type = null;#[ORM\Column(type: 'text', nullable: true)]private ?string $evaluationPromptTemplate = null;#[ORM\ManyToOne(targetEntity: 'Poll', inversedBy: 'questions')]private ?Poll $poll = null;#[ORM\OneToMany(mappedBy: 'question', targetEntity: 'QuestionOption', cascade: ['persist', 'remove'], orphanRemoval: true)]private Collection $options;public function __construct(){$this->options = new ArrayCollection();}public function __toString(): string{return $this->question;}public function getId(): ?int{return $this->id;}public function getQuestion(): ?string{return $this->question;}public function setQuestion(?string $question): self{$this->question = $question;return $this;}public function getType(): ?string{return $this->type;}public function setType(?string $type): self{if (!\in_array($type, [self::TYPE_NUMBER, self::TYPE_TEXT, self::TYPE_OPTION], true)) {throw new \InvalidArgumentException('Invalid type.');}$this->type = $type;return $this;}public function getPoll(): ?Poll{return $this->poll;}public function setPoll(?Poll $poll): self{$this->poll = $poll;return $this;}public function getOptions(): Collection{return $this->options;}public function setOptions(Collection $options): self{$this->options = $options;return $this;}public function addOption(QuestionOption $option): self{$this->options->add($option);return $this;}public function removeOption(QuestionOption $option): self{$this->options->removeElement($option);return $this;}public function getEvaluationPromptTemplate(): ?string{return $this->evaluationPromptTemplate;}public function setEvaluationPromptTemplate(?string $evaluationPromptTemplate): self{$this->evaluationPromptTemplate = $evaluationPromptTemplate;return $this;}}