<?php
namespace App\Entity;
use App\Repository\ItemSizeCategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ItemSizeCategoryRepository::class)]
class ItemSizeCategory
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\OneToMany(mappedBy: 'category', targetEntity: ItemSize::class, orphanRemoval: true)]
private $sizes;
public function __construct()
{
$this->sizes = 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;
}
/**
* @return Collection<int, ItemSize>
*/
public function getSizes(): Collection
{
return $this->sizes;
}
public function addSize(ItemSize $size): self
{
if (!$this->sizes->contains($size)) {
$this->sizes[] = $size;
$size->setCategory($this);
}
return $this;
}
public function removeSize(ItemSize $size): self
{
if ($this->sizes->removeElement($size)) {
// set the owning side to null (unless already changed)
if ($size->getCategory() === $this) {
$size->setCategory(null);
}
}
return $this;
}
}