<?php


namespace App\Model\Entities;

use App\Model\Exceptions\Db\NullValueException;
use App\Model\Interfaces\IEntity;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\MappedSuperclass
 */
abstract class BaseEntity implements IEntity
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer")
     */
    protected $id;

    /**
     * @return int
     */
    public function getId() : int
    {
        return $this->id;
    }

    /**
     * Empty string is not NULL, so it can be saved to DB
     * @param $value
     * @throws NullValueException
     */
    protected function validateNotNullValue($value)
    {
        if (empty($value)) {
            throw new NullValueException();
        }
    }
}