<?php


namespace AutoAdmin\Bundle\Content\Entity;

use AutoAdmin\Bundle\Content\Entity\Traits\IdTrait;
use AutoAdmin\Bundle\Content\Model\LocaleInterface;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Table(name: 'locale')]
#[ORM\Index(columns: ['code'])]
#[ORM\Entity(repositoryClass: 'AutoAdmin\Bundle\Content\Repository\LocaleRepository')]
class Locale implements LocaleInterface
{
    use IdTrait;

    #[ORM\Column(name: 'code', type: Types::STRING, length: 5)]
    protected ?string $code;

    public function __construct(?string $code = null)
    {
        $this->code = $code;
    }

    public function __toString(): string
    {
        return $this->getCode();
    }

    public function getCode(): string
    {
        return $this->code;
    }

    public function setCode(string $code): self
    {
        $this->code = $code;

        return $this;
    }
}
