<?php
namespace App\CasinoBundle\Entity;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use App\CmsBundle\Entity\IdTrait;
use App\CmsBundle\Entity\TimeStampedTrait;
use App\ProfileBundle\Entity\User;
use Exception;
/**
* @ORM\Entity(
* repositoryClass="App\CasinoBundle\Repository\UserReviewRepository"
* )
* @ORM\Table(
* name="user_review"
* )
*/
class UserReview
{
use IdTrait, TimeStampedTrait;
/**
* @ORM\ManyToOne(targetEntity="App\ProfileBundle\Entity\User", inversedBy="userReviews")
* @ORM\JoinColumn(nullable=false)
*/
private User $user;
/**
* @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Casino", inversedBy="userReviews")
* @ORM\JoinColumn(nullable=false)
*/
private Casino $casino;
/**
* @ORM\Column(type="float", nullable=false)
*/
private float $score;
/**
* @ORM\Column(type="text", nullable=false)
*/
private string $detailedScore;
/**
* @ORM\Column(type="text", nullable=false)
*/
private string $comment;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $reply = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $pros = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $cons = null;
/**
* @ORM\Column(type="integer", nullable=false, options={"default"=0})
*/
private int $status = 0;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default"=false})
*/
private bool $isRead = false;
/**
* @var int
*/
private int $count = 0;
/**
* @var string
*/
private string $country = '';
/**
* @return float
*/
public function getScore(): float
{
return $this->score;
}
/**
* @param float $score
* @return $this
*/
public function setScore(float $score): self
{
$this->score = $score;
return $this;
}
/**
* @return array
*/
public function getDetailedScore(): array
{
return json_decode($this->detailedScore, true);
}
/**
* @param array $detailedScore
* @return $this
*/
public function setDetailedScore(array $detailedScore): self
{
$this->detailedScore = json_encode($detailedScore);
return $this;
}
/**
* @return string
*/
public function getComment(): string
{
return $this->comment;
}
/**
* @param string $comment
* @return $this
*/
public function setComment(string $comment): self
{
$this->comment = $comment;
return $this;
}
/**
* @return ?array
* @throws Exception
*/
public function getReply(): ?array
{
$data = json_decode($this->reply, true);
if (!empty($data)) {
return [
'text' => $data['text'] ?? '',
'date' => isset($data['date']) ? (new DateTime(!is_array($data['date']) ? $data['date'] : $data['date']['date'])) : null,
'read_date' => isset($data['read_date']) ? (new DateTime(!is_array($data['read_date']) ? $data['read_date'] : $data['read_date']['date'])) : null,
'is_read' => $data['is_read'] ?? false,
'active' => $data['active'] ?? false
];
}
return $data;
}
/**
* @param ?array $reply
* @return $this
*/
public function setReply(?array $reply): self
{
$this->reply = json_encode($reply);
return $this;
}
/**
* @return ?string
*/
public function getPros(): ?string
{
return $this->pros;
}
/**
* @param ?string $pros
* @return $this
*/
public function setPros(?string $pros): self
{
$this->pros = $pros;
return $this;
}
/**
* @return ?string
*/
public function getCons(): ?string
{
return $this->cons;
}
/**
* @param ?string $cons
* @return $this
*/
public function setCons(?string $cons): self
{
$this->cons = $cons;
return $this;
}
/**
* @return int
*/
public function getStatus(): int
{
return $this->status;
}
/**
* @param int $status
* @return $this
*/
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
/**
* @return User
*/
public function getUser(): User
{
return $this->user;
}
/**
* @param User $user
* @return $this
*/
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Casino
*/
public function getCasino(): Casino
{
return $this->casino;
}
/**
* @param Casino $casino
* @return $this
*/
public function setCasino(Casino $casino): self
{
$this->casino = $casino;
return $this;
}
/**
* @return int
*/
public function getCount(): int
{
return $this->count;
}
/**
* @return string
*/
public function getCountry(): string
{
return $this->country;
}
/**
* @return bool
*/
public function getIsRead(): bool
{
return $this->isRead;
}
/**
* @param bool $isRead
* @return $this
*/
public function setIsRead(bool $isRead): self
{
$this->isRead = $isRead;
return $this;
}
}