src/Entity/Room.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RoomRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassRoomRepository::class)]
  8. class Room
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type"integer")]
  13.     protected int $id;
  14.     #[ORM\Column(type"integer"length6)]
  15.     private ?int $roomId;
  16.     #[ORM\Column(type"string"length100nullabletrue)]
  17.     private ?string $owner;
  18.     #[ORM\Column]
  19.     private ?bool $status false;
  20.     #[ORM\Column(type"string"length100nullabletrue)]
  21.     private ?string $gameMode 'classic';
  22.     #[ORM\Column(type"simple_array"nullabletrue)]
  23.     private ?array $mapName;
  24.     #[ORM\OneToMany(mappedBy'room'targetEntityUser::class)]
  25.     private Collection $hunters;
  26.     public function __construct()
  27.     {
  28.         $this->hunters = new ArrayCollection();
  29.     }
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getRoomId(): ?int
  35.     {
  36.         return $this->roomId;
  37.     }
  38.     public function setRoomId(int $roomId): self
  39.     {
  40.         $this->roomId $roomId;
  41.         return $this;
  42.     }
  43.     public function getOwner(): ?string
  44.     {
  45.         return $this->owner;
  46.     }
  47.     public function setOwner(?string $owner): self
  48.     {
  49.         $this->owner $owner;
  50.         return $this;
  51.     }
  52.     public function getStatus(): ?bool
  53.     {
  54.         return $this->status;
  55.     }
  56.     public function setStatus(bool $status): self
  57.     {
  58.         $this->status $status;
  59.         return $this;
  60.     }
  61.     public function toggleStatus(): self
  62.     {
  63.         $this->lock = !$this->lock;
  64.         return $this;
  65.     }
  66.     public function getGameMode(): ?string
  67.     {
  68.         return $this->gameMode;
  69.     }
  70.     public function setGameMode(?string $gameMode): self
  71.     {
  72.         $this->gameMode $gameMode;
  73.         return $this;
  74.     }
  75.     public function getMapName(): ?array
  76.     {
  77.         return $this->mapName;
  78.     }
  79.     public function setMapName(?array $mapName): self
  80.     {
  81.         $this->mapName $mapName;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection<int, User>
  86.      */
  87.     public function getHunters(): Collection
  88.     {
  89.         return $this->hunters;
  90.     }
  91.     public function addHunter(User $hunter): self
  92.     {
  93.         if (!$this->hunters->contains($hunter)) {
  94.             $this->hunters->add($hunter);
  95.             $hunter->setRoom($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeHunter(User $hunter): self
  100.     {
  101.         if ($this->hunters->removeElement($hunter)) {
  102.             // set the owning side to null (unless already changed)
  103.             if ($hunter->getRoom() === $this) {
  104.                 $hunter->setRoom(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109. }