<?php
namespace App\Entity;
use App\Repository\CountryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\Ignore;
/**
* @ORM\Entity(repositoryClass=CountryRepository::class)
*/
class Country
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @Groups({"atpmatch_result:list", "atpmatch_result:item","country:list", "country:item","round:list", "round:item","drawline:list", "drawline:item","event:list","event:item"})
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180)
* @Groups({"atpmatch_result:list", "atpmatch_result:item","country:list", "country:item","player:list", "player:item","round:list", "round:item","drawline:list", "drawline:item","event:list","event:item"})
*/
private $name;
/**
* @ORM\Column(type="string", length=3)
* @Groups({"atpmatch_result:list", "atpmatch_result:item", "country:list", "country:item","player:list", "player:item","round:list", "round:item","drawline:list", "drawline:item","event:list","event:item"})
*/
private $code;
/**
* @ORM\Column(type="string", length=3)
* @Groups({"atpmatch_result:list", "atpmatch_result:item","country:list", "country:item","player:list", "player:item","event:list","event:item","round:list", "round:item"})
*/
private $longCode;
/**
* @ORM\Column(type="string", length=180)
* @Groups({"country:list", "country:item","player:list", "player:item"})
*/
private $region;
/**
* @ORM\OneToMany(targetEntity=Player::class, mappedBy="country")
* @Ignore()
*/
private $players;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="country")
* @Ignore()
*/
private $users;
/**
* @var string
*/
private $flag;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $sortOrder;
public function __construct()
{
$this->players = new ArrayCollection();
}
public function __toString()
{
return $this->getName();
}
/**
* @return Collection|Player[]
*/
public function getPlayers(): Collection
{
return $this->players;
}
public function addPlayer(Player $player): self
{
if (!$this->players->contains($player)) {
$this->players[] = $player;
$player->setCountry($this);
}
return $this;
}
public function removePlayer(Player $player): self
{
if ($this->players->removeElement($player)) {
// set the owning side to null (unless already changed)
if ($player->getCountry() === $this) {
$player->setCountry(null);
}
}
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setCountry($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getCountry() === $this) {
$user->setCountry(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id): void
{
$this->id = $id;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name): void
{
$this->name = $name;
}
/**
* @return mixed
*/
public function getCode()
{
return $this->code;
}
/**
* @param mixed $code
*/
public function setCode($code): void
{
$this->code = $code;
}
/**
* @return mixed
*/
public function getLongCode()
{
return $this->longCode;
}
/**
* @param $longCode
*/
public function setLongCode($longCode): void
{
$this->longCode = $longCode;
}
/**
* @return mixed
*/
public function getRegion()
{
return $this->region;
}
/**
* @param mixed $region
*/
public function setRegion($region): void
{
$this->region = $region;
}
/**
* @return string
* @Groups({"country:list", "country:item","player:list", "player:item"})
*/
public function getFlag(): ?string
{
return $this->flag;
}
/**
* @param string $flag
*/
public function setFlag(string $flag): void
{
$this->flag = $flag;
}
public function getSortOrder(): ?int
{
return $this->sortOrder;
}
public function setSortOrder(?int $sortOrder): self
{
$this->sortOrder = $sortOrder;
return $this;
}
}