<?php

namespace App\Entity;

use App\Repository\ReleaseMetadataRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * Metadata related to a release.
 *
 * Could be pulled from an external source (MusicBrainz, Discogs, …) or filled by hand. A release should be usable
 * without associated metadata, but these metadata should always have a 1-1 relation to an existing release.
 */
#[ORM\Entity(repositoryClass: ReleaseMetadataRepository::class)]
class ReleaseMetadata
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\OneToOne(inversedBy: 'metadata', cascade: ['persist', 'remove'])]
    #[ORM\JoinColumn(nullable: false)]
    private ?Release $release = null;

    #[ORM\Column(nullable: true)]
    private ?int $year = null;

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

    public function getRelease(): ?Release
    {
        return $this->release;
    }

    public function setRelease(Release $release): static
    {
        $this->release = $release;

        return $this;
    }

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

    public function setYear(?int $year): static
    {
        $this->year = $year;

        return $this;
    }
}