src/Entity/QuizMention.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\QuizMentionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity(repositoryClassQuizMentionRepository::class)]
  9. class QuizMention
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $mention null;
  17.     #[ORM\Column]
  18.     #[Assert\LessThan(propertyPath"pourcentageMax")]
  19.     #[Assert\Range(
  20.         min0,
  21.         max100,
  22.         notInRangeMessage'Pourcentage doit étre entre {{ min }} et {{ max }}',
  23.     )]
  24.     private ?float $pourcentage null;
  25.     #[ORM\Column]
  26.     #[Assert\GreaterThan(propertyPath"pourcentage")]
  27.     #[Assert\Range(
  28.         min0,
  29.         max100,
  30.         notInRangeMessage'Pourcentage doit étre entre {{ min }} et {{ max }}',
  31.     )]
  32.     private ?float $pourcentageMax null;
  33.     #[ORM\ManyToOne(inversedBy'mention')]
  34.     private ?QuizResultat $quizResultat null;
  35.     #[ORM\OneToMany(mappedBy'mention'targetEntityPourcentageQuiz::class)]
  36.     private Collection $pourcentageQuizzes;
  37.     public function __construct()
  38.     {
  39.         $this->pourcentageQuizzes = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getMention(): ?string
  46.     {
  47.         return $this->mention;
  48.     }
  49.     public function setMention(string $mention): self
  50.     {
  51.         $this->mention $mention;
  52.         return $this;
  53.     }
  54.     public function getPourcentage(): ?float
  55.     {
  56.         return $this->pourcentage;
  57.     }
  58.     public function setPourcentage(float $pourcentage): self
  59.     {
  60.         $this->pourcentage $pourcentage;
  61.         return $this;
  62.     }
  63.     public function getPourcentageMax(): ?float
  64.     {
  65.         return $this->pourcentageMax;
  66.     }
  67.     public function setPourcentageMax(float $pourcentageMax): self
  68.     {
  69.         $this->pourcentageMax $pourcentageMax;
  70.         return $this;
  71.     }
  72.     public function getQuizResultat(): ?QuizResultat
  73.     {
  74.         return $this->quizResultat;
  75.     }
  76.     public function setQuizResultat(?QuizResultat $quizResultat): self
  77.     {
  78.         $this->quizResultat $quizResultat;
  79.         return $this;
  80.     }
  81.     public function __toString()
  82.     {
  83.         return $this->mention ?? '' ;
  84.     }
  85.     /**
  86.      * @return Collection<int, PourcentageQuiz>
  87.      */
  88.     public function getPourcentageQuizzes(): Collection
  89.     {
  90.         return $this->pourcentageQuizzes;
  91.     }
  92.     public function addPourcentageQuiz(PourcentageQuiz $pourcentageQuiz): self
  93.     {
  94.         if (!$this->pourcentageQuizzes->contains($pourcentageQuiz)) {
  95.             $this->pourcentageQuizzes->add($pourcentageQuiz);
  96.             $pourcentageQuiz->setMention($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removePourcentageQuiz(PourcentageQuiz $pourcentageQuiz): self
  101.     {
  102.         if ($this->pourcentageQuizzes->removeElement($pourcentageQuiz)) {
  103.             // set the owning side to null (unless already changed)
  104.             if ($pourcentageQuiz->getMention() === $this) {
  105.                 $pourcentageQuiz->setMention(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110. }