<?php
namespace App\Core\Entity;
use App\Core\DataObjectInterface\CompetitionInterface;
use App\Core\Repository\CompetitionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CompetitionRepository::class)
*/
class Competition implements CompetitionInterface
{
public const STATE_SCHEDULED = 'scheduled';
public const STATE_IN_PROGRESS = 'in_progress';
public const COMPETITION_STATES = [
self::STATE_SCHEDULED,
self::STATE_IN_PROGRESS,
];
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\Column(type="string", length=255)
*/
private string $name;
/**
* @ORM\Column(type="integer", length=11)
*/
private string $externalId;
/**
* @ORM\Column(type="string", length=255)
*/
private string $state = self::STATE_SCHEDULED;
/**
* @ORM\ManyToOne(targetEntity="Tournament")
* @ORM\JoinColumn(name="tournament_id", referencedColumnName="id")
*/
private Tournament $tournament;
/**
* @ORM\ManyToMany(targetEntity="Team", mappedBy="competitions")
*/
private Collection $teams;
/**
* @ORM\OneToMany(targetEntity="MatchFormat", mappedBy="competition")
*/
private Collection $formats;
public function __construct()
{
$this->formats = new 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 getExternalId(): int
{
return $this->externalId;
}
public function setExternalId(int $externalId): self
{
$this->externalId = $externalId;
return $this;
}
public function getState(): string
{
return $this->state;
}
public function setState(string $state): self
{
$this->state = $state;
return $this;
}
public function getTournament(): Tournament
{
return $this->tournament;
}
public function setTournament(Tournament $tournament): self
{
$this->tournament = $tournament;
return $this;
}
public function getTeams(): Collection
{
return $this->teams;
}
public function setTeams(Collection $teams): self
{
$this->teams = $teams;
return $this;
}
public function getFormats(): Collection
{
return $this->formats;
}
}