<?php
namespace App\Core\Entity;
use App\Core\DataObjectInterface\TeamInterface;
use App\Core\Repository\TeamRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=TeamRepository::class)
*/
class Team implements TeamInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\Column(type="string", length=255)
*/
private string $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $type;
/**
* @ORM\ManyToOne(targetEntity="Player")
* @ORM\JoinColumn(name="player1_id", referencedColumnName="id")
*/
private ?Player $player1;
/**
* @ORM\ManyToOne(targetEntity="Player")
* @ORM\JoinColumn(name="player2_id", referencedColumnName="id")
*/
private ?Player $player2;
/**
* @ORM\ManyToMany(targetEntity="Competition", inversedBy="teams")
* @ORM\JoinTable(name="team_competition",
* joinColumns={@ORM\JoinColumn(name="team_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="competition_id", referencedColumnName="id")}
* )
*/
private Collection $competitions;
public function __construct(string $name = null, Collection $competitions = null)
{
if ($competitions === null) {
$this->competitions = 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 getCompetitions(): Collection
{
return $this->competitions;
}
public function addCompetition(Competition $competition): self
{
if (!$this->competitions->contains($competition)) {
$this->competitions[] = $competition;
}
return $this;
}
public function removeCompetition(Competition $competition): self
{
if (!$this->competitions->contains($competition)) {
$this->competitions->removeElement($competition);
}
return $this;
}
public function setCompetitions(Collection $competitions): self
{
$this->competitions = $competitions;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getPlayer1(): ?Player
{
return $this->player1;
}
public function setPlayer1(?Player $player1): self
{
$this->player1 = $player1;
return $this;
}
public function getPlayer2(): ?Player
{
return $this->player2;
}
public function setPlayer2(?Player $player2): self
{
$this->player2 = $player2;
return $this;
}
}