<?php
declare(strict_types=1);
namespace App\Entity\Profile;
use AngelGamez\TranslatableBundle\Entity\TranslatableValue;
use App\Repository\ProfileInventoryItemRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Table(name: 'profile_inventory_items')]
#[UniqueConstraint(name: 'profile_inventory_item_uri_unique', columns: ['uri_identity'])]
#[ORM\Entity(repositoryClass: ProfileInventoryItemRepository::class)]
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'profiles')]
class ProfileInventoryItem
{
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'smallint')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[Groups(['preview', 'listing'])]
private int $id;
#[ORM\Column(name: 'type', type: 'string', length: 32)]
#[Groups(['preview', 'listing'])]
private string $type;
#[ORM\Column(name: 'name', type: 'translatable')]
#[Groups(['preview', 'listing'])]
private TranslatableValue $name;
#[ORM\Column(name: 'uri_identity', type: 'string', length: 128)]
#[Groups(['preview', 'listing'])]
private string $uriIdentity;
#[ORM\Column(name: 'sort', type: 'smallint')]
#[Groups(['preview', 'listing'])]
private int $sort;
public function __construct(TranslatableValue $name, string $uriIdentity, string $type, int $sort)
{
if (!in_array($type, ProfileInventoryItemType::all(), true)) {
throw new \InvalidArgumentException(sprintf('Unsupported profile inventory item type "%s".', $type));
}
$this->name = $name;
$this->uriIdentity = $uriIdentity;
$this->type = $type;
$this->sort = $sort;
}
public function getId(): int
{
return $this->id;
}
public function getType(): string
{
return $this->type;
}
public function getName(): TranslatableValue
{
return $this->name;
}
public function getUriIdentity(): string
{
return $this->uriIdentity;
}
public function getSort(): int
{
return $this->sort;
}
}