src/Entity/Question.php line 13

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.     /**
  8.      * @ORM\Entity(repositoryClass=QuestionRepository::class)
  9.      */
  10.     class Question
  11.     {
  12.         const TYPE_RADIO    'radio';
  13.         const TYPE_CHECKBOX 'checkbox';
  14.         /**
  15.          * @ORM\Id
  16.          * @ORM\GeneratedValue
  17.          * @ORM\Column(type="integer")
  18.          */
  19.         private $id;
  20.         /**
  21.          * @ORM\Column(type="string", length=255)
  22.          */
  23.         private $text;
  24.         /**
  25.          * @ORM\Column(type="string", length=255, nullable=true)
  26.          */
  27.         private $image;
  28.         /**
  29.          * @ORM\Column(type="string", length=255, options={"default":self::TYPE_RADIO})
  30.          */
  31.         private $type self::TYPE_RADIO;
  32.         /**
  33.          * @ORM\Column(type="integer", nullable=true)
  34.          */
  35.         private $timeLimit;
  36.         /**
  37.          * @ORM\Column(type="integer", nullable=true)
  38.          */
  39.         private $orderIndex;
  40.         /**
  41.          * @ORM\OneToMany(targetEntity=Answer::class, mappedBy="question")
  42.          */
  43.         private $answers;
  44.         /**
  45.          * @ORM\ManyToOne(targetEntity=Quizz::class, inversedBy="questions")
  46.          */
  47.         private $quizz;
  48.         /**
  49.          * @var string
  50.          *
  51.          * @ORM\Column(type="text")
  52.          */
  53.         protected $explanation;
  54.         public function __construct()
  55.         {
  56.             $this->answers = new ArrayCollection();
  57.         }
  58.         public function getId(): ?int
  59.         {
  60.             return $this->id;
  61.         }
  62.         public function getText(): ?string
  63.         {
  64.             return $this->text;
  65.         }
  66.         public function setTextstring $text ): self
  67.         {
  68.             $this->text $text;
  69.             return $this;
  70.         }
  71.         public function getImage(): ?string
  72.         {
  73.             return $this->image;
  74.         }
  75.         public function setImage( ?string $image ): self
  76.         {
  77.             $this->image $image;
  78.             return $this;
  79.         }
  80.         public function getType(): ?string
  81.         {
  82.             return $this->type;
  83.         }
  84.         public function setTypestring $type ): self
  85.         {
  86.             $this->type $type;
  87.             return $this;
  88.         }
  89.         public function getTimeLimit(): ?int
  90.         {
  91.             return $this->timeLimit;
  92.         }
  93.         public function setTimeLimit( ?int $timeLimit ): self
  94.         {
  95.             $this->timeLimit $timeLimit;
  96.             return $this;
  97.         }
  98.         public function getOrderIndex(): ?int
  99.         {
  100.             return $this->orderIndex;
  101.         }
  102.         public function setOrderIndex( ?int $orderIndex ): self
  103.         {
  104.             $this->orderIndex $orderIndex;
  105.             return $this;
  106.         }
  107.         /**
  108.          * @return Collection|Answer[]
  109.          */
  110.         public function getAnswers(): Collection
  111.         {
  112.             return $this->answers;
  113.         }
  114.         public function addAnswerAnswer $answer ): self
  115.         {
  116.             if ( !$this->answers->contains$answer ) ) {
  117.                 $this->answers[] = $answer;
  118.                 $answer->setQuestion$this );
  119.             }
  120.             return $this;
  121.         }
  122.         public function removeAnswerAnswer $answer ): self
  123.         {
  124.             if ( $this->answers->removeElement$answer ) ) {
  125.                 // set the owning side to null (unless already changed)
  126.                 if ( $answer->getQuestion() === $this ) {
  127.                     $answer->setQuestionNULL );
  128.                 }
  129.             }
  130.             return $this;
  131.         }
  132.         public function getQuizz(): ?Quizz
  133.         {
  134.             return $this->quizz;
  135.         }
  136.         public function setQuizz( ?Quizz $quizz ): self
  137.         {
  138.             $this->quizz $quizz;
  139.             return $this;
  140.         }
  141.         /**
  142.          * @return string
  143.          */
  144.         public function getExplanation(): string
  145.         {
  146.             return $this->explanation;
  147.         }
  148.         /**
  149.          * @param string $explanation
  150.          * @return Question
  151.          */
  152.         public function setExplanation(string $explanation): Question
  153.         {
  154.             $this->explanation $explanation;
  155.             return $this;
  156.         }
  157.     }