<?php


namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;

/**
 * @ORM\Entity
 * @ORM\Table(
 *     name="judge_titles",
 *     indexes={
 *         @ORM\Index(name="jt_year_idx", columns={"year"})
 *     }
 * )
 */
class JudgeTitle implements JsonSerializable
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @var int
     */
    private $id;

    /**
     * @ORM\Column(name="year", type="integer")
     * @var int
     */
    private $year;

    /**
     * @ORM\Column(name="title", type="text", length=1500)
     * @var string
     */
    private $title;

    /**
     * @ORM\ManyToOne(targetEntity="Judge", inversedBy="titles")
     * @ORM\JoinColumn(name="judge_id", referencedColumnName="id")
     * @var Judge
     */
    private $judge;

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

    /**
     * @param int $id
     * @return JudgeTitle
     */
    public function setId(?int $id): JudgeTitle
    {
        $this->id = $id;
        return $this;
    }

    /**
     * @return int
     */
    public function getYear(): ?int
    {
        return $this->year;
    }

    /**
     * @param int $year
     * @return JudgeTitle
     */
    public function setYear(int $year): JudgeTitle
    {
        $this->year = $year;
        return $this;
    }

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

    /**
     * @param string $title
     * @return JudgeTitle
     */
    public function setTitle(string $title): JudgeTitle
    {
        $this->title = $title;
        return $this;
    }

    /**
     * @return Judge
     */
    public function getJudge(): ?Judge
    {
        return $this->judge;
    }

    /**
     * @param Judge $judge
     * @return JudgeTitle
     */
    public function setJudge(?Judge $judge): JudgeTitle
    {
        $this->judge = $judge;
        return $this;
    }


    /**
     * @return array
     */
    public function jsonSerialize()
    {
        return [
            'id' => $this->getId(),
            'year' => $this->getYear(),
            'title' => $this->getTitle(),
        ];
    }
}
