<?php

namespace App\Domain\Scraping\Infrastructure\Persistence\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'manga_preferred_sources')]
#[ORM\UniqueConstraint(name: 'UNIQ_manga_preferred_sources_manga_id', columns: ['manga_id'])]
class MangaPreferredSourceEntity
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(type: 'integer')]
    private int $mangaId;

    #[ORM\Column(type: Types::JSON)]
    private array $orderedSourceIds = [];

    #[ORM\Column]
    private \DateTimeImmutable $createdAt;

    #[ORM\Column]
    private \DateTimeImmutable $updatedAt;

    public function __construct()
    {
        $this->createdAt = new \DateTimeImmutable();
        $this->updatedAt = new \DateTimeImmutable();
    }

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

    public function getMangaId(): int
    {
        return $this->mangaId;
    }

    public function setMangaId(int $mangaId): self
    {
        $this->mangaId = $mangaId;
        $this->updatedAt = new \DateTimeImmutable();

        return $this;
    }

    public function getOrderedSourceIds(): array
    {
        return $this->orderedSourceIds;
    }

    public function setOrderedSourceIds(array $orderedSourceIds): self
    {
        $this->orderedSourceIds = $orderedSourceIds;
        $this->updatedAt = new \DateTimeImmutable();

        return $this;
    }

    public function getCreatedAt(): \DateTimeImmutable
    {
        return $this->createdAt;
    }

    public function getUpdatedAt(): \DateTimeImmutable
    {
        return $this->updatedAt;
    }
}
