<?php
namespace App\Entity;
use App\Repository\BeatCategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: BeatCategoryRepository::class)]
class BeatCategory
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\ManyToMany(targetEntity: Beat::class, mappedBy: 'category')]
private Collection $beats;
public function __construct()
{
$this->beats = new ArrayCollection();
}
public function __toString()
{
return (string)$this->getName();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, Beat>
*/
public function getBeats(): Collection
{
return $this->beats;
}
public function addBeat(Beat $beat): static
{
if (!$this->beats->contains($beat)) {
$this->beats->add($beat);
$beat->addCategory($this);
}
return $this;
}
public function removeBeat(Beat $beat): static
{
if ($this->beats->removeElement($beat)) {
$beat->removeCategory($this);
}
return $this;
}
}