src/Entity/Question.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\QuestionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassQuestionRepository::class)]
  8. class Question
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $content null;
  16.     #[ORM\Column(length50)]
  17.     private ?string $type null;
  18.     #[ORM\Column]
  19.     private ?int $position null;
  20.     #[ORM\Column(type'boolean')]
  21.     private bool $required true;
  22.     #[ORM\ManyToOne(inversedBy'questions')]
  23.     #[ORM\JoinColumn(nullablefalse)]
  24.     private ?Survey $survey null;
  25.     #[ORM\OneToMany(mappedBy'question'targetEntityQuestionOption::class, orphanRemovaltruecascade: ['persist'])]
  26.     private Collection $options;
  27.     #[ORM\OneToMany(mappedBy'question'targetEntityQuestionResponse::class, orphanRemovaltrue)]
  28.     private Collection $responses;
  29.     #[ORM\Column(type'json'nullabletrue)]
  30.     private ?array $conditions null;
  31.     public function __construct()
  32.     {
  33.         $this->options = new ArrayCollection();
  34.         $this->responses = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getContent(): ?string
  41.     {
  42.         return $this->content;
  43.     }
  44.     public function setContent(string $content): self
  45.     {
  46.         $this->content $content;
  47.         return $this;
  48.     }
  49.     public function getType(): ?string
  50.     {
  51.         return $this->type;
  52.     }
  53.     public function setType(string $type): self
  54.     {
  55.         $this->type $type;
  56.         return $this;
  57.     }
  58.     public function getPosition(): ?int
  59.     {
  60.         return $this->position;
  61.     }
  62.     public function setPosition(int $position): self
  63.     {
  64.         $this->position $position;
  65.         return $this;
  66.     }
  67.     public function isRequired(): bool
  68.     {
  69.         return $this->required;
  70.     }
  71.     public function setRequired(bool $required): self
  72.     {
  73.         $this->required $required;
  74.         return $this;
  75.     }
  76.     public function getSurvey(): ?Survey
  77.     {
  78.         return $this->survey;
  79.     }
  80.     public function setSurvey(?Survey $survey): self
  81.     {
  82.         $this->survey $survey;
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, QuestionOption>
  87.      */
  88.     public function getOptions(): Collection
  89.     {
  90.         return $this->options;
  91.     }
  92.     public function addOption(QuestionOption $option): self
  93.     {
  94.         if (!$this->options->contains($option)) {
  95.             $this->options->add($option);
  96.             $option->setQuestion($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeOption(QuestionOption $option): self
  101.     {
  102.         if ($this->options->removeElement($option)) {
  103.             if ($option->getQuestion() === $this) {
  104.                 $option->setQuestion(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return Collection<int, QuestionResponse>
  111.      */
  112.     public function getResponses(): Collection
  113.     {
  114.         return $this->responses;
  115.     }
  116.     public function addResponse(QuestionResponse $response): self
  117.     {
  118.         if (!$this->responses->contains($response)) {
  119.             $this->responses->add($response);
  120.             $response->setQuestion($this);
  121.         }
  122.         return $this;
  123.     }
  124.     public function removeResponse(QuestionResponse $response): self
  125.     {
  126.         if ($this->responses->removeElement($response)) {
  127.             if ($response->getQuestion() === $this) {
  128.                 $response->setQuestion(null);
  129.             }
  130.         }
  131.         return $this;
  132.     }
  133.     public function getConditions(): ?array
  134.     {
  135.         return $this->conditions;
  136.     }
  137.     public function setConditions(?array $conditions): self
  138.     {
  139.         $this->conditions $conditions;
  140.         return $this;
  141.     }
  142. }