src/CasinoBundle/Entity/Currency.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use App\CmsBundle\Entity\PublishedTrait;
  4. use App\CmsBundle\Entity\SlugTrait;
  5. use App\CmsBundle\Entity\TimeStampedTrait;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use App\CmsBundle\Entity\IdTrait;
  10. /**
  11.  * Currency
  12.  *
  13.  * @ORM\Table(
  14.  *     name="currency",
  15.  *     uniqueConstraints={
  16.  *          @ORM\UniqueConstraint(name="currency_alphabetic_code_uindex", columns={"alphabetic_code"}),
  17.  *          @ORM\UniqueConstraint(name="currency_slug_uindex", columns={"slug"})
  18.  *     },
  19.  *     indexes={
  20.  *          @ORM\Index(name="currency_published_index", columns={"published"})
  21.  *     }
  22.  * )
  23.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\CurrencyRepository")
  24.  * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="one_day")
  25.  * @ORM\HasLifecycleCallbacks()
  26.  */
  27. class Currency
  28. {
  29.     use IdTrait;
  30.     use NameTrait;
  31.     use SlugTrait;
  32.     use AliasTrait;
  33.     use SignTrait;
  34.     use PublishedTrait;
  35.     use TimeStampedTrait;
  36.     /**
  37.      * @var string|null
  38.      *
  39.      * @ORM\Column(name="alphabetic_code", type="string", length=255, nullable=true)
  40.      */
  41.     private $alphabeticCode;
  42.     /**
  43.      * @var int|null
  44.      *
  45.      * @ORM\Column(name="numeric_code", type="integer", nullable=true)
  46.      */
  47.     private $numericCode;
  48.     /**
  49.      * @var int|null
  50.      *
  51.      * @ORM\Column(name="sign_position", type="integer", nullable=true)
  52.      */
  53.     private ?int $signPosition;
  54.     /**
  55.      * @ORM\ManyToMany(targetEntity="Country", mappedBy="currencies", cascade={"persist"})
  56.      */
  57.     private $countries;
  58.     /**
  59.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="currencies", cascade={"persist"})
  60.      */
  61.     private $casinos;
  62.     /**
  63.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\NewBonus", mappedBy="currencies", cascade={"persist"})
  64.      */
  65.     private $newBonuses;
  66.     /**
  67.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Alias", mappedBy="currency", cascade={"persist"}, orphanRemoval=true)
  68.      */
  69.     private Collection $aliases;
  70.     /**
  71.      * Currency constructor.
  72.      */
  73.     public function __construct()
  74.     {
  75.         $this->countries = new ArrayCollection();
  76.         $this->casinos = new ArrayCollection();
  77.         $this->aliases = new ArrayCollection();
  78.         $this->newBonuses = new ArrayCollection();
  79.     }
  80.     /**
  81.      * @return string|null
  82.      */
  83.     public function __toString()
  84.     {
  85.         return $this->getAlphabeticCode();
  86.     }
  87.     /**
  88.      * @return null|string
  89.      */
  90.     public function getAlphabeticCode(): ?string
  91.     {
  92.         return $this->alphabeticCode;
  93.     }
  94.     /**
  95.      * @param null|string $alphabeticCode
  96.      */
  97.     public function setAlphabeticCode(?string $alphabeticCode): self
  98.     {
  99.         $this->alphabeticCode $alphabeticCode;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return int|null
  104.      */
  105.     public function getNumericCode(): ?int
  106.     {
  107.         return $this->numericCode;
  108.     }
  109.     /**
  110.      * @param int|null $numericCode
  111.      */
  112.     public function setNumericCode(?int $numericCode): self
  113.     {
  114.         $this->numericCode $numericCode;
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return Collection|Country[]
  119.      */
  120.     public function getCountries(): Collection
  121.     {
  122.         return $this->countries;
  123.     }
  124.     /**
  125.      * @param Country $country
  126.      * @return $this
  127.      */
  128.     public function addCountry(Country $country): self
  129.     {
  130.         if (!$this->countries->contains($country)) {
  131.             $this->countries[] = $country;
  132.             $country->addCurrency($this);
  133.         }
  134.         return $this;
  135.     }
  136.     /**
  137.      * @param Country $country
  138.      * @return $this
  139.      */
  140.     public function removeCountry(Country $country): self
  141.     {
  142.         if ($this->countries->contains($country)) {
  143.             $this->countries->removeElement($country);
  144.             $country->removeCurrency($this);
  145.         }
  146.         return $this;
  147.     }
  148.     /**
  149.      * @return Collection|Casino[]
  150.      */
  151.     public function getCasinos(): Collection
  152.     {
  153.         return $this->casinos;
  154.     }
  155.     public function addCasino(Casino $casino): self
  156.     {
  157.         if (!$this->casinos->contains($casino)) {
  158.             $this->casinos[] = $casino;
  159.             $casino->addCurrency($this);
  160.         }
  161.         return $this;
  162.     }
  163.     public function removeCasino(Casino $casino): self
  164.     {
  165.         if ($this->casinos->contains($casino)) {
  166.             $this->casinos->removeElement($casino);
  167.             $casino->removeCurrency($this);
  168.         }
  169.         return $this;
  170.     }
  171.     /**
  172.      * @return Collection|NewBonus[]
  173.      */
  174.     public function getNewBonuses(): Collection
  175.     {
  176.         return $this->newBonuses;
  177.     }
  178.     /**
  179.      * @param NewBonus $newBonus
  180.      * @return $this
  181.      */
  182.     public function addNewBonus(NewBonus $newBonus): self
  183.     {
  184.         if (!$this->newBonuses->contains($newBonus)) {
  185.             $this->newBonuses[] = $newBonus;
  186.             $newBonus->addCurrency($this);
  187.         }
  188.         return $this;
  189.     }
  190.     /**
  191.      * @param NewBonus $newBonus
  192.      * @return $this
  193.      */
  194.     public function removeNewBonus(NewBonus $newBonus): self
  195.     {
  196.         if ($this->newBonuses->contains($newBonus)) {
  197.             $this->newBonuses->removeElement($newBonus);
  198.             $newBonus->removeCurrency($this);
  199.         }
  200.         return $this;
  201.     }
  202.     /**
  203.      * @return int|null
  204.      */
  205.     public function getSignPosition(): ?int
  206.     {
  207.         return $this->signPosition;
  208.     }
  209.     /**
  210.      * @param int|null $signPosition
  211.      * @return $this
  212.      */
  213.     public function setSignPosition(?int $signPosition): self
  214.     {
  215.         $this->signPosition $signPosition;
  216.         return $this;
  217.     }
  218. }