<?php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Repository\CountryRepository;
/**
* Country
*
* @ORM\Table(name="country", indexes={@ORM\Index(name="regionID", columns={"region_id"})})
* @ORM\Entity(repositoryClass=CountryRepository::class)
*/
class Country
{
/**
* @var int
*
* @ORM\Column(name="id", type="smallint", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @Groups({CspCountry::SERIALIZATION_GROUP_COUNTRIES_PER_CSP})
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=60, nullable=false)
* @Groups({
* CspCountry::SERIALIZATION_GROUP_COUNTRIES_PER_CSP,
* CustomerExcludeCsp::SERIALIZATION_GROUP_EXCLUDED_CSP_COUNTRY,
* CspCountry::SERIALIZATION_GROUP_GET_ITEM
* })
*/
private $name;
/**
* @var \Region
*
* @ORM\ManyToOne(targetEntity="Region")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="region_id", referencedColumnName="id")
* })
*/
private $region;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Csp", mappedBy="country")
*/
private $csp;
/**
* Constructor
*/
public function __construct()
{
$this->csp = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getRegion(): ?Region
{
return $this->region;
}
public function setRegion(?Region $region): self
{
$this->region = $region;
return $this;
}
/**
* @return Collection<int, Csp>
*/
public function getCsp(): Collection
{
return $this->csp;
}
public function addCsp(Csp $csp): self
{
if (!$this->csp->contains($csp)) {
$this->csp[] = $csp;
$csp->addCountry($this);
}
return $this;
}
public function removeCsp(Csp $csp): self
{
if ($this->csp->removeElement($csp)) {
$csp->removeCountry($this);
}
return $this;
}
}