<?php
namespace App\CasinoBundle\Entity;
use CommerceGuys\Enum\AbstractEnum;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Yokai\EnumBundle\Enum\EnumInterface;
use Yokai\EnumBundle\Enum\EnumWithClassAsNameTrait;
/**
* Review
*
* @ORM\Table(name="review")
* @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\ReviewRepository")
*/
class Review
{
const POSITIVE = 1;
const NEGATIVE = 0;
const OPTIONS = [
'positive' => self::POSITIVE,
'negative' => self::NEGATIVE,
];
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="note", type="text")
*/
private $note;
/**
* @var string
*
* @ORM\Column(name="type", type="smallint", nullable=true)
*/
private $type;
/**
* @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Casino", inversedBy="reviews")
* @ORM\JoinColumn(nullable=false)
*/
private $casino;
/**
* @ORM\Column(name="position", type="integer")
*/
private $position;
public function __toString()
{
return $this->note;
}
public function getChoices()
{
return self::OPTIONS;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
public function getNote(): string
{
return $this->note;
}
public function setNote(string $note): self
{
$this->note = $note;
return $this;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getType(): int
{
return $this->type;
}
public function getCasino(): ?Casino
{
return $this->casino;
}
public function setCasino(?Casino $casino): self
{
$this->casino = $casino;
return $this;
}
public function setPosition(int $position)
{
$this->position = $position;
}
public function getPosition(): int
{
return $this->position ?? 0;
}
public function getTypeSign()
{
switch ($this->getType()) {
case 0:
return 'negative';
case 1:
return 'positive';
}
return '';
}
}