src/Core/Entity/Team.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Core\Entity;
  3. use App\Core\DataObjectInterface\TeamInterface;
  4. use App\Core\Repository\TeamRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=TeamRepository::class)
  10.  */
  11. class Team implements TeamInterface
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private int $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private string $name;
  23.     /**
  24.      * @ORM\Column(type="string", length=255, nullable=true)
  25.      */
  26.     private ?string $type;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity="Player")
  29.      * @ORM\JoinColumn(name="player1_id", referencedColumnName="id")
  30.      */
  31.     private ?Player $player1;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity="Player")
  34.      * @ORM\JoinColumn(name="player2_id", referencedColumnName="id")
  35.      */
  36.     private ?Player $player2;
  37.     /**
  38.      * @ORM\ManyToMany(targetEntity="Competition", inversedBy="teams")
  39.      * @ORM\JoinTable(name="team_competition",
  40.      *      joinColumns={@ORM\JoinColumn(name="team_id", referencedColumnName="id")},
  41.      *      inverseJoinColumns={@ORM\JoinColumn(name="competition_id", referencedColumnName="id")}
  42.      * )
  43.      */
  44.     private Collection $competitions;
  45.     public function __construct(string $name nullCollection $competitions null)
  46.     {
  47.         if ($competitions === null) {
  48.             $this->competitions = new ArrayCollection();
  49.         }
  50.     }
  51.     public function getId(): int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name): self
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getCompetitions(): Collection
  65.     {
  66.         return $this->competitions;
  67.     }
  68.     public function addCompetition(Competition $competition): self
  69.     {
  70.         if (!$this->competitions->contains($competition)) {
  71.             $this->competitions[] = $competition;
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeCompetition(Competition $competition): self
  76.     {
  77.         if (!$this->competitions->contains($competition)) {
  78.             $this->competitions->removeElement($competition);
  79.         }
  80.         return $this;
  81.     }
  82.     public function setCompetitions(Collection $competitions): self
  83.     {
  84.         $this->competitions $competitions;
  85.         return $this;
  86.     }
  87.     public function getType(): ?string
  88.     {
  89.         return $this->type;
  90.     }
  91.     public function setType(?string $type): self
  92.     {
  93.         $this->type $type;
  94.         return $this;
  95.     }
  96.     public function getPlayer1(): ?Player
  97.     {
  98.         return $this->player1;
  99.     }
  100.     public function setPlayer1(?Player $player1): self
  101.     {
  102.         $this->player1 $player1;
  103.         return $this;
  104.     }
  105.     public function getPlayer2(): ?Player
  106.     {
  107.         return $this->player2;
  108.     }
  109.     public function setPlayer2(?Player $player2): self
  110.     {
  111.         $this->player2 $player2;
  112.         return $this;
  113.     }
  114. }