<?php


namespace App\Model\Entities\Localization;

use App\Model\Entities\BaseNamedRecord;
use App\Model\Entities\Security\User;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="language")
 */
class Language extends BaseNamedRecord
{
    const IN_PROGRESS = 'in_progress';
    const AVAILABLE = 'available';

    /**
     * @ORM\Column(type="string", unique=true)
     */
    protected $identifier;

    public function __construct(User $createdBy)
    {
        parent::__construct($createdBy);

        $this->setState(self::IN_PROGRESS);
    }


    /**
     * @return mixed
     */
    public function getIdentifier()
    {
        return $this->identifier;
    }

    /**
     * @param mixed $identifier
     */
    public function setIdentifier($identifier)
    {
        $this->identifier = strtolower($identifier);
    }

    protected function isValidState(string $state) : bool
    {
        return in_array($state, [self::IN_PROGRESS, self::AVAILABLE]);
    }



}