<?php

namespace App\Entity;

use App\Repository\OgLiveRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

#[ORM\Entity(repositoryClass: OgLiveRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_FILENAME', fields: ['filename'])]
#[UniqueEntity(fields: ['filename'], message: 'validators.og_live.filename.unique')]
class OgLive extends AbstractEntity
{
    use NameableTrait;
    use SynchronizedTrait;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $downloadUrl = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $checksum = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $distribution = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $kernel = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $architecture = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $revision = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $directory = null;

    #[ORM\Column(length: 255, nullable: false)]
    private ?string $filename = null;

    #[ORM\Column(nullable: true)]
    private ?bool $installed = false;

    #[ORM\Column(nullable: true)]
    private ?bool $isDefault = false;

    /**
     * @var Collection<int, Client>
     */
    #[ORM\OneToMany(mappedBy: 'ogLive', targetEntity: Client::class)]
    private Collection $clients;

    #[ORM\Column(length: 255)]
    private ?string $status = null;

    #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
    private ?\DateTimeInterface $date = null;

    public function __construct()
    {
        parent::__construct();
        $this->clients = new ArrayCollection();
    }

    public function getDownloadUrl(): ?string
    {
        return $this->downloadUrl;
    }

    public function setDownloadUrl(?string $downloadUrl): static
    {
        $this->downloadUrl = $downloadUrl;

        return $this;
    }

    public function getChecksum(): ?string
    {
        return $this->checksum;
    }

    public function setChecksum(?string $checksum): static
    {
        $this->checksum = $checksum;

        return $this;
    }

    public function getDistribution(): ?string
    {
        return $this->distribution;
    }

    public function setDistribution(?string $distribution): static
    {
        $this->distribution = $distribution;

        return $this;
    }

    public function getKernel(): ?string
    {
        return $this->kernel;
    }

    public function setKernel(?string $kernel): static
    {
        $this->kernel = $kernel;

        return $this;
    }

    public function getArchitecture(): ?string
    {
        return $this->architecture;
    }

    public function setArchitecture(?string $architecture): static
    {
        $this->architecture = $architecture;

        return $this;
    }

    public function getRevision(): ?string
    {
        return $this->revision;
    }

    public function setRevision(?string $revision): static
    {
        $this->revision = $revision;

        return $this;
    }

    public function getDirectory(): ?string
    {
        return $this->directory;
    }

    public function setDirectory(?string $directory): static
    {
        $this->directory = $directory;

        return $this;
    }

    public function getFilename(): ?string
    {
        return $this->filename;
    }

    public function setFilename(?string $filename): static
    {
        $this->filename = $filename;

        return $this;
    }

    public function isInstalled(): ?bool
    {
        return $this->installed;
    }

    public function setInstalled(?bool $installed): static
    {
        $this->installed = $installed;

        return $this;
    }

    public function getIsDefault(): ?bool
    {
        return $this->isDefault;
    }

    public function setIsDefault(?bool $isDefault): void
    {
        $this->isDefault = $isDefault;
    }

    /**
     * @return Collection<int, Client>
     */
    public function getClients(): Collection
    {
        return $this->clients;
    }

    public function addClient(Client $client): static
    {
        if (!$this->clients->contains($client)) {
            $this->clients->add($client);
            $client->setOgLive($this);
        }

        return $this;
    }

    public function removeClient(Client $client): static
    {
        if ($this->clients->removeElement($client)) {
            // set the owning side to null (unless already changed)
            if ($client->getOgLive() === $this) {
                $client->setOgLive(null);
            }
        }

        return $this;
    }

    public function getStatus(): ?string
    {
        return $this->status;
    }

    public function setStatus(string $status): static
    {
        $this->status = $status;

        return $this;
    }

    public function getDate(): ?\DateTimeInterface
    {
        return $this->date;
    }

    public function setDate(?\DateTimeInterface $date): static
    {
        $this->date = $date;

        return $this;
    }
}
