src/CasinoBundle/Entity/UserReview.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\CmsBundle\Entity\IdTrait;
  6. use App\CmsBundle\Entity\TimeStampedTrait;
  7. use App\ProfileBundle\Entity\User;
  8. use Exception;
  9. /**
  10.  * @ORM\Entity(
  11.  *     repositoryClass="App\CasinoBundle\Repository\UserReviewRepository"
  12.  * )
  13.  * @ORM\Table(
  14.  *     name="user_review"
  15.  * )
  16.  */
  17. class UserReview
  18. {
  19.     use IdTraitTimeStampedTrait;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity="App\ProfileBundle\Entity\User", inversedBy="userReviews")
  22.      * @ORM\JoinColumn(nullable=false)
  23.      */
  24.     private User $user;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Casino", inversedBy="userReviews")
  27.      * @ORM\JoinColumn(nullable=false)
  28.      */
  29.     private Casino $casino;
  30.     /**
  31.      * @ORM\Column(type="float", nullable=false)
  32.      */
  33.     private float $score;
  34.     /**
  35.      * @ORM\Column(type="text", nullable=false)
  36.      */
  37.     private string $detailedScore;
  38.     /**
  39.      * @ORM\Column(type="text", nullable=false)
  40.      */
  41.     private string $comment;
  42.     /**
  43.      * @ORM\Column(type="text", nullable=true)
  44.      */
  45.     private ?string $reply null;
  46.     /**
  47.      * @ORM\Column(type="text", nullable=true)
  48.      */
  49.     private ?string $pros null;
  50.     /**
  51.      * @ORM\Column(type="text", nullable=true)
  52.      */
  53.     private ?string $cons null;
  54.     /**
  55.      * @ORM\Column(type="integer", nullable=false, options={"default"=0})
  56.      */
  57.     private int $status 0;
  58.     /**
  59.      * @ORM\Column(type="boolean", nullable=false, options={"default"=false})
  60.      */
  61.     private bool $isRead false;
  62.     /**
  63.      * @var int
  64.      */
  65.     private int $count 0;
  66.     /**
  67.      * @var string
  68.      */
  69.     private string $country '';
  70.     /**
  71.      * @return float
  72.      */
  73.     public function getScore(): float
  74.     {
  75.         return $this->score;
  76.     }
  77.     /**
  78.      * @param float $score
  79.      * @return $this
  80.      */
  81.     public function setScore(float $score): self
  82.     {
  83.         $this->score $score;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return array
  88.      */
  89.     public function getDetailedScore(): array
  90.     {
  91.         return json_decode($this->detailedScoretrue);
  92.     }
  93.     /**
  94.      * @param array $detailedScore
  95.      * @return $this
  96.      */
  97.     public function setDetailedScore(array $detailedScore): self
  98.     {
  99.         $this->detailedScore json_encode($detailedScore);
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return string
  104.      */
  105.     public function getComment(): string
  106.     {
  107.         return $this->comment;
  108.     }
  109.     /**
  110.      * @param string $comment
  111.      * @return $this
  112.      */
  113.     public function setComment(string $comment): self
  114.     {
  115.         $this->comment $comment;
  116.         return $this;
  117.     }
  118.     /**
  119.      * @return ?array
  120.      * @throws Exception
  121.      */
  122.     public function getReply(): ?array
  123.     {
  124.         $data json_decode($this->replytrue);
  125.         if (!empty($data)) {
  126.             return [
  127.                 'text' => $data['text'] ?? '',
  128.                 'date' => isset($data['date']) ? (new DateTime(!is_array($data['date']) ? $data['date'] : $data['date']['date'])) : null,
  129.                 'read_date' => isset($data['read_date']) ? (new DateTime(!is_array($data['read_date']) ? $data['read_date'] : $data['read_date']['date'])) : null,
  130.                 'is_read' => $data['is_read'] ?? false,
  131.                 'active' => $data['active'] ?? false
  132.             ];
  133.         }
  134.         return $data;
  135.     }
  136.     /**
  137.      * @param ?array $reply
  138.      * @return $this
  139.      */
  140.     public function setReply(?array $reply): self
  141.     {
  142.         $this->reply json_encode($reply);
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return ?string
  147.      */
  148.     public function getPros(): ?string
  149.     {
  150.         return $this->pros;
  151.     }
  152.     /**
  153.      * @param ?string $pros
  154.      * @return $this
  155.      */
  156.     public function setPros(?string $pros): self
  157.     {
  158.         $this->pros $pros;
  159.         return $this;
  160.     }
  161.     /**
  162.      * @return ?string
  163.      */
  164.     public function getCons(): ?string
  165.     {
  166.         return $this->cons;
  167.     }
  168.     /**
  169.      * @param ?string $cons
  170.      * @return $this
  171.      */
  172.     public function setCons(?string $cons): self
  173.     {
  174.         $this->cons $cons;
  175.         return $this;
  176.     }
  177.     /**
  178.      * @return int
  179.      */
  180.     public function getStatus(): int
  181.     {
  182.         return $this->status;
  183.     }
  184.     /**
  185.      * @param int $status
  186.      * @return $this
  187.      */
  188.     public function setStatus(int $status): self
  189.     {
  190.         $this->status $status;
  191.         return $this;
  192.     }
  193.     /**
  194.      * @return User
  195.      */
  196.     public function getUser(): User
  197.     {
  198.         return $this->user;
  199.     }
  200.     /**
  201.      * @param User $user
  202.      * @return $this
  203.      */
  204.     public function setUser(User $user): self
  205.     {
  206.         $this->user $user;
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Casino
  211.      */
  212.     public function getCasino(): Casino
  213.     {
  214.         return $this->casino;
  215.     }
  216.     /**
  217.      * @param Casino $casino
  218.      * @return $this
  219.      */
  220.     public function setCasino(Casino $casino): self
  221.     {
  222.         $this->casino $casino;
  223.         return $this;
  224.     }
  225.     /**
  226.      * @return int
  227.      */
  228.     public function getCount(): int
  229.     {
  230.         return $this->count;
  231.     }
  232.     /**
  233.      * @return string
  234.      */
  235.     public function getCountry(): string
  236.     {
  237.         return $this->country;
  238.     }
  239.     /**
  240.      * @return bool
  241.      */
  242.     public function getIsRead(): bool
  243.     {
  244.         return $this->isRead;
  245.     }
  246.     /**
  247.      * @param bool $isRead
  248.      * @return $this
  249.      */
  250.     public function setIsRead(bool $isRead): self
  251.     {
  252.         $this->isRead $isRead;
  253.         return $this;
  254.     }
  255. }