<?php

namespace App\Entity;

use App\Behavior\Timestampable;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\ExtraTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * @ORM\Entity(repositoryClass=ExtraTypeRepository::class)
 * @ORM\HasLifecycleCallbacks()
 */
class ExtraType
{
    use Timestampable;

    public function __construct()
    {
        //$this->extra = new ArrayCollection();
    }

    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=50)
     */
    private $title;

    /**
     * @ORM\Column(type="boolean")
     */
    private $isMandatory;

    /**
     * @ORM\Column(type="integer")
     */
    private $minimalChoice;

    /**
     * @ORM\Column(type="integer")
     */
    private $maximumChoice;

    /**
     * @ORM\OneToMany(targetEntity=Extra::class, mappedBy="extraType", orphanRemoval=true)
     */
    private $extra;

    /**
     * @ORM\ManyToOne(targetEntity=Menu::class, inversedBy="extraType")
     */
    private $menu;

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

    public function getTitle(): ?string
    {
        return $this->title;
    }

    public function setTitle(string $title): self
    {
        $this->title = $title;

        return $this;
    }

    public function isIsMandatory(): ?bool
    {
        return $this->isMandatory;
    }

    public function setIsMandatory(bool $isMandatory): self
    {
        $this->isMandatory = $isMandatory;

        return $this;
    }

    public function getMinimalChoice(): ?int
    {
        return $this->minimalChoice;
    }

    public function setMinimalChoice(int $minimalChoice): self
    {
        $this->minimalChoice = $minimalChoice;

        return $this;
    }

    public function getMaximumChoice(): ?int
    {
        return $this->maximumChoice;
    }

    public function setMaximumChoice(int $maximumChoice): self
    {
        $this->maximumChoice = $maximumChoice;

        return $this;
    }

    /**
     * Get the value of extra
     */
    public function getExtra()
    {
        return $this->extra;
    }

    /**
     * Set the value of extra
     *
     * @return  self
     */
    public function setExtra($extra)
    {
        $this->extra = $extra;

        return $this;
    }

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

    public function getMenuName()
    {
        return $this->menu->getName();
    }

    /**
     * Get the value of menu
     */
    public function getMenu()
    {
        return $this->menu;
    }

    /**
     * Set the value of menu
     *
     * @return  self
     */
    public function setMenu($menu)
    {
        $this->menu = $menu;

        return $this;
    }
}
