src/CasinoBundle/Entity/Review.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use CommerceGuys\Enum\AbstractEnum;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Yokai\EnumBundle\Enum\EnumInterface;
  7. use Yokai\EnumBundle\Enum\EnumWithClassAsNameTrait;
  8. /**
  9.  * Review
  10.  *
  11.  * @ORM\Table(name="review")
  12.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\ReviewRepository")
  13.  */
  14. class Review
  15. {
  16.     const POSITIVE 1;
  17.     const NEGATIVE 0;
  18.     const OPTIONS = [
  19.         'positive' => self::POSITIVE,
  20.         'negative' => self::NEGATIVE,
  21.     ];
  22.     /**
  23.      * @var int
  24.      *
  25.      * @ORM\Column(name="id", type="integer", nullable=false)
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue(strategy="IDENTITY")
  28.      */
  29.     private $id;
  30.     /**
  31.      * @var string
  32.      *
  33.      * @ORM\Column(name="note", type="text")
  34.      */
  35.     private $note;
  36.     /**
  37.      * @var string
  38.      *
  39.      * @ORM\Column(name="type", type="smallint", nullable=true)
  40.      */
  41.     private $type;
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Casino", inversedBy="reviews")
  44.      * @ORM\JoinColumn(nullable=false)
  45.      */
  46.     private $casino;
  47.     /**
  48.      * @ORM\Column(name="position", type="integer")
  49.      */
  50.     private $position;
  51.     public function __toString()
  52.     {
  53.         return $this->note;
  54.     }
  55.     public function getChoices()
  56.     {
  57.         return self::OPTIONS;
  58.     }
  59.     /**
  60.      * @return int
  61.      */
  62.     public function getId(): int
  63.     {
  64.         return $this->id;
  65.     }
  66.     /**
  67.      * @param int $id
  68.      */
  69.     public function setId(int $id): void
  70.     {
  71.         $this->id $id;
  72.     }
  73.     public function getNote(): string
  74.     {
  75.         return $this->note;
  76.     }
  77.     public function setNote(string $note): self
  78.     {
  79.         $this->note $note;
  80.         return $this;
  81.     }
  82.     public function setType(int $type): self
  83.     {
  84.         $this->type $type;
  85.         return $this;
  86.     }
  87.     public function getType(): int
  88.     {
  89.         return $this->type;
  90.     }
  91.     public function getCasino(): ?Casino
  92.     {
  93.         return $this->casino;
  94.     }
  95.     public function setCasino(?Casino $casino): self
  96.     {
  97.         $this->casino $casino;
  98.         return $this;
  99.     }
  100.     public function setPosition(int $position)
  101.     {
  102.         $this->position $position;
  103.     }
  104.     public function getPosition(): int
  105.     {
  106.         return $this->position ?? 0;
  107.     }
  108.     public function getTypeSign()
  109.     {
  110.         switch ($this->getType()) {
  111.             case 0:
  112.                 return 'negative';
  113.             case 1:
  114.                 return 'positive';
  115.         }
  116.         return '';
  117.     }
  118. }