src/CasinoBundle/Entity/Country.php line 31

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\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use App\CmsBundle\Entity\IdTrait;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\CountryRepository")
  12.  * @ORM\Table(name="country",
  13.  *     uniqueConstraints={
  14.  *          @ORM\UniqueConstraint(name="country_alpha2_uindex", columns={"alpha2"}),
  15.  *          @ORM\UniqueConstraint(name="country_alpha3_uindex", columns={"alpha3"}),
  16.  *          @ORM\UniqueConstraint(name="country_name_uindex", columns={"name"}),
  17.  *          @ORM\UniqueConstraint(name="country_slug_uindex", columns={"slug"}),
  18.  *          @ORM\UniqueConstraint(name="country_capitail_city_uindex", columns={"capital_city_id"})
  19.  *    },
  20.  *    indexes={
  21.  *          @ORM\Index(name="country_lat_index", columns={"lat"}),
  22.  *          @ORM\Index(name="country_lng_index", columns={"lng"}),
  23.  *          @ORM\Index(name="country_published_index", columns={"published"})
  24.  *    }
  25.  *)
  26.  * @ORM\HasLifecycleCallbacks()
  27.  */
  28. class Country
  29. {
  30.     use IdTrait;
  31.     use NameTrait;
  32.     use SlugTrait;
  33.     use PublishedTrait;
  34.     use AliasTrait;
  35.     use TimeStampedTrait;
  36.     /**
  37.      * @var string|null
  38.      *
  39.      * @ORM\Column(name="alpha2", type="string", length=2, nullable=true)
  40.      */
  41.     private ?string $alpha2;
  42.     /**
  43.      * @var string|null
  44.      *
  45.      * @ORM\Column(name="alpha3", type="string", length=3, nullable=true)
  46.      */
  47.     private ?string $alpha3;
  48.     /**
  49.      * @var float|null
  50.      *
  51.      * @ORM\Column(name="lat", type="decimal", precision=11, scale=8, nullable=true)
  52.      */
  53.     private ?float $lat;
  54.     /**
  55.      * @var float|null
  56.      *
  57.      * @ORM\Column(name="lng", type="decimal", precision=11, scale=8, nullable=true)
  58.      */
  59.     private ?float $lng;
  60.     /**
  61.      * @ORM\OneToOne(targetEntity="App\CasinoBundle\Entity\City")
  62.      * @ORM\JoinColumn(nullable=true, name="capital_city_id")
  63.      */
  64.     private ?City $capitalCity;
  65.     /**
  66.      * @var string|null
  67.      *
  68.      * @ORM\Column(name="continent", type="string", length=2, nullable=true)
  69.      */
  70.     private ?string $continent;
  71.     /**
  72.      * @var string|null
  73.      *
  74.      * @ORM\Column(name="nationality", type="string", length=255, nullable=true)
  75.      */
  76.     private ?string $nationality;
  77.     /**
  78.      * @ORM\ManyToMany(targetEntity="Currency", inversedBy="countries", cascade={"persist"})
  79.      */
  80.     private Collection $currencies;
  81.     /**
  82.      * @ORM\ManyToMany(targetEntity="Language", inversedBy="countries")
  83.      */
  84.     private Collection $languages;
  85.     /**
  86.      * @ORM\OneToMany(targetEntity="City", mappedBy="country")
  87.      */
  88.     private Collection $cities;
  89.     /**
  90.      * @ORM\OneToMany(targetEntity="State", mappedBy="country")
  91.      */
  92.     private Collection $states;
  93.     /**
  94.      * @ORM\ManyToOne(targetEntity="Region", inversedBy="countries")
  95.      */
  96.     private ?Region $region;
  97.     /**
  98.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Visit", mappedBy="country")
  99.      */
  100.     private Collection $visits;
  101.     /**
  102.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="allowedCountries")
  103.      */
  104.     private Collection $allowedCasinos;
  105.     /**
  106.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="restrictedCountries")
  107.      */
  108.     private Collection $restrictedCasinos;
  109.     /**
  110.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="restrictedCountriesFact")
  111.      */
  112.     private Collection $restrictedCasinosFact;
  113.     /**
  114.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="jurisdictions")
  115.      */
  116.     private Collection $jurisdictionCasinos;
  117.     /**
  118.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="brandRegistration")
  119.      */
  120.     private Collection $brandRegistrationCasinos;
  121.     /**
  122.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="serverLocation")
  123.      */
  124.     private Collection $serverLocationCasinos;
  125.     /**
  126.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Alias", mappedBy="country", cascade={"persist"}, orphanRemoval=true)
  127.      */
  128.     private Collection $aliases;
  129.     /**
  130.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\OfflineCasino", mappedBy="country", cascade={"persist"}, orphanRemoval=true)
  131.      */
  132.     private Collection $offlineCasinos;
  133.     /**
  134.      * @var int|null
  135.      *
  136.      * @ORM\Column(name="brand_reputation", type="integer", nullable=true)
  137.      */
  138.     private ?int $brandReputation;
  139.     /**
  140.      * @var int|null
  141.      *
  142.      * @ORM\Column(name="server_security_level", type="integer", nullable=true)
  143.      */
  144.     private ?int $serverSecurityLevel;
  145.     /**
  146.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Licence", mappedBy="country", cascade={"persist"}, orphanRemoval=true)
  147.      */
  148.     private Collection $licences;
  149.     /**
  150.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\NewBonus", mappedBy="countries", cascade={"persist"})
  151.      */
  152.     private Collection $newBonuses;
  153.     public function __construct()
  154.     {
  155.         $this->currencies = new ArrayCollection();
  156.         $this->languages = new ArrayCollection();
  157.         $this->cities = new ArrayCollection();
  158.         $this->states = new ArrayCollection();
  159.         $this->visits = new ArrayCollection();
  160.         $this->allowedCasinos = new ArrayCollection();
  161.         $this->restrictedCasinos = new ArrayCollection();
  162.         $this->restrictedCasinosFact = new ArrayCollection();
  163.         $this->jurisdictionCasinos = new ArrayCollection();
  164.         $this->brandRegistrationCasinos = new ArrayCollection();
  165.         $this->serverLocationCasinos = new ArrayCollection();
  166.         $this->aliases = new ArrayCollection();
  167.         $this->licences = new ArrayCollection();
  168.         $this->newBonuses = new ArrayCollection();
  169.     }
  170.     /**
  171.      * @return string
  172.      */
  173.     public function __toString()
  174.     {
  175.         return $this->name;
  176.     }
  177.     /**
  178.      * @return string
  179.      */
  180.     public function getNameWithAlpha2(): string
  181.     {
  182.         return $this->getName() . ' - ' $this->getAlpha2();
  183.     }
  184.     /**
  185.      * @return Collection
  186.      */
  187.     public function getCities(): Collection
  188.     {
  189.         return $this->cities;
  190.     }
  191.     /**
  192.      * @param City $city
  193.      * @return $this
  194.      */
  195.     public function addCity(City $city): self
  196.     {
  197.         if (!$this->cities->contains($city)) {
  198.             $this->cities[] = $city;
  199.         }
  200.         return $this;
  201.     }
  202.     /**
  203.      * @param City $city
  204.      * @return $this
  205.      */
  206.     public function removeCity(City $city): self
  207.     {
  208.         if ($this->cities->contains($city)) {
  209.             $this->cities->removeElement($city);
  210.         }
  211.         return $this;
  212.     }
  213.     /**
  214.      * @return ArrayCollection
  215.      */
  216.     public function getStates()
  217.     {
  218.         return $this->states;
  219.     }
  220.     /**
  221.      * @return string|null
  222.      */
  223.     public function getAlpha2(): ?string
  224.     {
  225.         return $this->alpha2;
  226.     }
  227.     /**
  228.      * @param string $alpha2
  229.      * @return $this
  230.      */
  231.     public function setAlpha2(string $alpha2): self
  232.     {
  233.         $this->alpha2 $alpha2;
  234.         return $this;
  235.     }
  236.     /**
  237.      * @return null|string
  238.      */
  239.     public function getAlpha3(): ?string
  240.     {
  241.         return $this->alpha3;
  242.     }
  243.     /**
  244.      * @param string|null $alpha3
  245.      * @return $this
  246.      */
  247.     public function setAlpha3(?string $alpha3): self
  248.     {
  249.         $this->alpha3 $alpha3;
  250.         return $this;
  251.     }
  252.     /**
  253.      * @return float|null
  254.      */
  255.     public function getLat(): ?float
  256.     {
  257.         return $this->lat;
  258.     }
  259.     /**
  260.      * @param float|null $lat
  261.      * @return $this
  262.      */
  263.     public function setLat(?float $lat): self
  264.     {
  265.         $this->lat $lat;
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return float|null
  270.      */
  271.     public function getLng(): ?float
  272.     {
  273.         return $this->lng;
  274.     }
  275.     /**
  276.      * @param float|null $lng
  277.      * @return $this
  278.      */
  279.     public function setLng(?float $lng): self
  280.     {
  281.         $this->lng $lng;
  282.         return $this;
  283.     }
  284.     /**
  285.      * @return null|string
  286.      */
  287.     public function getContinent(): ?string
  288.     {
  289.         return $this->continent;
  290.     }
  291.     /**
  292.      * @param null|string $continent
  293.      */
  294.     public function setContinent(?string $continent): void
  295.     {
  296.         $this->continent $continent;
  297.     }
  298.     /**
  299.      * @return null|string
  300.      */
  301.     public function getNationality(): ?string
  302.     {
  303.         return $this->nationality;
  304.     }
  305.     /**
  306.      * @param null|string $nationality
  307.      */
  308.     public function setNationality(?string $nationality): void
  309.     {
  310.         $this->nationality $nationality;
  311.     }
  312.     /**
  313.      * @return Collection
  314.      */
  315.     public function getCurrencies(): Collection
  316.     {
  317.         return $this->currencies;
  318.     }
  319.     /**
  320.      * @param Currency $currency
  321.      * @return $this
  322.      */
  323.     public function addCurrency(Currency $currency): self
  324.     {
  325.         if (!$this->currencies->contains($currency)) {
  326.             $this->currencies[] = $currency;
  327.         }
  328.         return $this;
  329.     }
  330.     /**
  331.      * @param Currency $currency
  332.      * @return $this
  333.      */
  334.     public function removeCurrency(Currency $currency): self
  335.     {
  336.         if ($this->currencies->contains($currency)) {
  337.             $this->currencies->removeElement($currency);
  338.         }
  339.         return $this;
  340.     }
  341.     /**
  342.      * @return Collection
  343.      */
  344.     public function getLanguages(): Collection
  345.     {
  346.         return $this->languages;
  347.     }
  348.     /**
  349.      * @param Language $language
  350.      * @return $this
  351.      */
  352.     public function addLanguage(Language $language): self
  353.     {
  354.         if (!$this->languages->contains($language)) {
  355.             $this->languages[] = $language;
  356.         }
  357.         return $this;
  358.     }
  359.     /**
  360.      * @param Language $language
  361.      * @return $this
  362.      */
  363.     public function removeLanguage(Language $language): self
  364.     {
  365.         if ($this->languages->contains($language)) {
  366.             $this->languages->removeElement($language);
  367.         }
  368.         return $this;
  369.     }
  370.     /**
  371.      * @return Collection
  372.      */
  373.     public function getVisits(): Collection
  374.     {
  375.         return $this->visits;
  376.     }
  377.     /**
  378.      * @param Visit $visit
  379.      * @return $this
  380.      */
  381.     public function addVisit(Visit $visit): self
  382.     {
  383.         if (!$this->visits->contains($visit)) {
  384.             $this->visits[] = $visit;
  385.             $visit->setCountry($this);
  386.         }
  387.         return $this;
  388.     }
  389.     /**
  390.      * @param Visit $visit
  391.      * @return $this
  392.      */
  393.     public function removeVisit(Visit $visit): self
  394.     {
  395.         if ($this->visits->contains($visit)) {
  396.             $this->visits->removeElement($visit);
  397.             // set the owning side to null (unless already changed)
  398.             if ($visit->getCountry() === $this) {
  399.                 $visit->setCountry(null);
  400.             }
  401.         }
  402.         return $this;
  403.     }
  404.     /**
  405.      * @return Collection
  406.      */
  407.     public function getAllowedCasinos(): Collection
  408.     {
  409.         return $this->allowedCasinos;
  410.     }
  411.     /**
  412.      * @param Casino $casino
  413.      * @return $this
  414.      */
  415.     public function addAllowedCasino(Casino $casino): self
  416.     {
  417.         if (!$this->allowedCasinos->contains($casino)) {
  418.             $this->allowedCasinos[] = $casino;
  419.             $casino->addAllowedCountry($this);
  420.         }
  421.         return $this;
  422.     }
  423.     /**
  424.      * @param Casino $casino
  425.      * @return $this
  426.      */
  427.     public function removeAllowedCasino(Casino $casino): self
  428.     {
  429.         if ($this->allowedCasinos->contains($casino)) {
  430.             $this->allowedCasinos->removeElement($casino);
  431.             $casino->removeAllowedCountry($this);
  432.         }
  433.         return $this;
  434.     }
  435.     /**
  436.      * @return Collection
  437.      */
  438.     public function getRestrictedCasinos(): Collection
  439.     {
  440.         return $this->restrictedCasinos;
  441.     }
  442.     /**
  443.      * @param Casino $casino
  444.      * @return $this
  445.      */
  446.     public function addRestrictedCasino(Casino $casino): self
  447.     {
  448.         if (!$this->restrictedCasinos->contains($casino)) {
  449.             $this->restrictedCasinos[] = $casino;
  450.             $casino->addRestrictedCountry($this);
  451.         }
  452.         return $this;
  453.     }
  454.     /**
  455.      * @param Casino $casino
  456.      * @return $this
  457.      */
  458.     public function removeRestrictedCasino(Casino $casino): self
  459.     {
  460.         if ($this->restrictedCasinos->contains($casino)) {
  461.             $this->restrictedCasinos->removeElement($casino);
  462.             $casino->removeRestrictedCountry($this);
  463.         }
  464.         return $this;
  465.     }
  466.     /**
  467.      * @return Collection
  468.      */
  469.     public function getRestrictedCasinosFact(): Collection
  470.     {
  471.         if (is_null($this->restrictedCasinosFact)) $this->restrictedCasinosFact = new ArrayCollection();
  472.         return $this->restrictedCasinosFact;
  473.     }
  474.     /**
  475.      * @param Casino $casino
  476.      * @return $this
  477.      */
  478.     public function addRestrictedCasinoFact(Casino $casino): self
  479.     {
  480.         if (!$this->getRestrictedCasinosFact()->contains($casino)) {
  481.             $this->restrictedCasinosFact[] = $casino;
  482.             $casino->addRestrictedCountryFact($this);
  483.         }
  484.         return $this;
  485.     }
  486.     /**
  487.      * @param Casino $casino
  488.      * @return $this
  489.      */
  490.     public function removeRestrictedCasinoFact(Casino $casino): self
  491.     {
  492.         if ($this->getRestrictedCasinosFact()->contains($casino)) {
  493.             $this->restrictedCasinosFact->removeElement($casino);
  494.             $casino->removeRestrictedCountryFact($this);
  495.         }
  496.         return $this;
  497.     }
  498.     /**
  499.      * @return Collection
  500.      */
  501.     public function getJurisdictionCasinos(): Collection
  502.     {
  503.         return $this->jurisdictionCasinos;
  504.     }
  505.     /**
  506.      * @param Casino $casino
  507.      * @return $this
  508.      */
  509.     public function addJurisdictionCasino(Casino $casino): self
  510.     {
  511.         if (!$this->jurisdictionCasinos->contains($casino)) {
  512.             $this->jurisdictionCasinos[] = $casino;
  513.             $casino->addJurisdiction($this);
  514.         }
  515.         return $this;
  516.     }
  517.     /**
  518.      * @param Casino $casino
  519.      * @return $this
  520.      */
  521.     public function removeJurisdictionCasino(Casino $casino): self
  522.     {
  523.         if ($this->jurisdictionCasinos->contains($casino)) {
  524.             $this->jurisdictionCasinos->removeElement($casino);
  525.             $casino->removeJurisdiction($this);
  526.         }
  527.         return $this;
  528.     }
  529.     /**
  530.      * @return Collection
  531.      */
  532.     public function getBrandRegistrationCasinos(): Collection
  533.     {
  534.         return $this->brandRegistrationCasinos;
  535.     }
  536.     /**
  537.      * @param Casino $casino
  538.      * @return $this
  539.      */
  540.     public function addBrandRegistrationCasino(Casino $casino): self
  541.     {
  542.         if (!$this->brandRegistrationCasinos->contains($casino)) {
  543.             $this->brandRegistrationCasinos[] = $casino;
  544.             $casino->addBrandRegistration($this);
  545.         }
  546.         return $this;
  547.     }
  548.     /**
  549.      * @param Casino $casino
  550.      * @return $this
  551.      */
  552.     public function removeBrandRegistrationCasino(Casino $casino): self
  553.     {
  554.         if ($this->brandRegistrationCasinos->contains($casino)) {
  555.             $this->brandRegistrationCasinos->removeElement($casino);
  556.             $casino->removeBrandRegistration($this);
  557.         }
  558.         return $this;
  559.     }
  560.     /**
  561.      * @return Collection
  562.      */
  563.     public function getServerLocationCasinos(): Collection
  564.     {
  565.         return $this->serverLocationCasinos;
  566.     }
  567.     /**
  568.      * @param Casino $casino
  569.      * @return $this
  570.      */
  571.     public function addServerLocationCasino(Casino $casino): self
  572.     {
  573.         if (!$this->serverLocationCasinos->contains($casino)) {
  574.             $this->serverLocationCasinos[] = $casino;
  575.             $casino->addServerLocation($this);
  576.         }
  577.         return $this;
  578.     }
  579.     /**
  580.      * @param Casino $casino
  581.      * @return $this
  582.      */
  583.     public function removeServerLocationCasino(Casino $casino): self
  584.     {
  585.         if ($this->serverLocationCasinos->contains($casino)) {
  586.             $this->serverLocationCasinos->removeElement($casino);
  587.             $casino->removeServerLocation($this);
  588.         }
  589.         return $this;
  590.     }
  591.     /**
  592.      * @param City|null $capitalCity
  593.      * @return $this
  594.      */
  595.     public function setCapitalCity(?City $capitalCity): self
  596.     {
  597.         $this->capitalCity $capitalCity;
  598.         return $this;
  599.     }
  600.     /**
  601.      * @return City|null
  602.      */
  603.     public function getCapitalCity(): ?City
  604.     {
  605.         return $this->capitalCity;
  606.     }
  607.     /**
  608.      * @param Region|null $region
  609.      * @return $this
  610.      */
  611.     public function setRegion(?Region $region): self
  612.     {
  613.         $this->region $region;
  614.         return $this;
  615.     }
  616.     /**
  617.      * @return Region|null
  618.      */
  619.     public function getRegion(): ?Region
  620.     {
  621.         return $this->region;
  622.     }
  623.     /**
  624.      * @return Collection
  625.      */
  626.     public function getLicences(): Collection
  627.     {
  628.         return $this->licences;
  629.     }
  630.     /**
  631.      * @param Licence $licence
  632.      * @return $this
  633.      */
  634.     public function addLicence(Licence $licence): self
  635.     {
  636.         if (!$this->licences->contains($licence)) {
  637.             $this->licences[] = $licence;
  638.             $licence->setCountry($this);
  639.         }
  640.         return $this;
  641.     }
  642.     /**
  643.      * @param Licence $licence
  644.      * @return $this
  645.      */
  646.     public function removeLicence(Licence $licence): self
  647.     {
  648.         if ($this->licences->contains($licence)) {
  649.             $this->licences->removeElement($licence);
  650.             $licence->setCountry(null);
  651.         }
  652.         return $this;
  653.     }
  654.     /**
  655.      * @param int $brandReputation
  656.      * @return $this
  657.      */
  658.     public function setBrandReputation(int $brandReputation): self
  659.     {
  660.         $this->brandReputation $brandReputation;
  661.         return $this;
  662.     }
  663.     /**
  664.      * @return int|null
  665.      */
  666.     public function getBrandReputation(): ?int
  667.     {
  668.         return $this->brandReputation;
  669.     }
  670.     /**
  671.      * @param int $serverSecurityLevel
  672.      * @return $this
  673.      */
  674.     public function setServerSecurityLevel(int $serverSecurityLevel): self
  675.     {
  676.         $this->serverSecurityLevel $serverSecurityLevel;
  677.         return $this;
  678.     }
  679.     /**
  680.      * @return int|null
  681.      */
  682.     public function getServerSecurityLevel(): ?int
  683.     {
  684.         return $this->serverSecurityLevel;
  685.     }
  686.     /**
  687.      * @return Collection
  688.      */
  689.     public function getNewBonuses(): Collection
  690.     {
  691.         return $this->newBonuses;
  692.     }
  693.     /**
  694.      * @param NewBonus $newBonus
  695.      * @return $this
  696.      */
  697.     public function addNewBonus(NewBonus $newBonus): self
  698.     {
  699.         if (!$this->newBonuses->contains($newBonus)) {
  700.             $this->newBonuses[] = $newBonus;
  701.             $newBonus->addCountry($this);
  702.         }
  703.         return $this;
  704.     }
  705.     /**
  706.      * @param NewBonus $newBonus
  707.      * @return $this
  708.      */
  709.     public function removeNewBonus(NewBonus $newBonus): self
  710.     {
  711.         if ($this->newBonuses->contains($newBonus)) {
  712.             $this->newBonuses->removeElement($newBonus);
  713.             $newBonus->removeCountry($this);
  714.         }
  715.         return $this;
  716.     }
  717. }