<?php

namespace App\Entity;

use App\Repository\ImageRepositoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: ImageRepositoryRepository::class)]
class ImageRepository extends AbstractEntity
{
    const string DEFAULT_USER = 'opengnsys';

    use NameableTrait;

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

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

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

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

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

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

    public function getIp(): ?string
    {
        return $this->ip;
    }

    public function setIp(string $ip): static
    {
        $this->ip = $ip;

        return $this;
    }

    public function getComments(): ?string
    {
        return $this->comments;
    }

    public function setComments(?string $comments): static
    {
        $this->comments = $comments;

        return $this;
    }

    /**
     * @return Collection<int, ImageImageRepository>
     */
    public function getImageImageRepositories(): Collection
    {
        return $this->imageImageRepositories;
    }

    public function addImageImageRepository(ImageImageRepository $imageImageRepository): static
    {
        if (!$this->imageImageRepositories->contains($imageImageRepository)) {
            $this->imageImageRepositories->add($imageImageRepository);
            $imageImageRepository->setRepository($this);
        }

        return $this;
    }

    public function removeImageImageRepository(ImageImageRepository $imageImageRepository): static
    {
        if ($this->imageImageRepositories->removeElement($imageImageRepository)) {
            // set the owning side to null (unless already changed)
            if ($imageImageRepository->getRepository() === $this) {
                $imageImageRepository->setRepository(null);
            }
        }

        return $this;
    }

    public function getUser(): ?string
    {
        return $this->user;
    }

    public function setUser(?string $user): static
    {
        $this->user = $user;

        return $this;
    }

    public function getSshPort(): ?string
    {
        return $this->sshPort;
    }

    public function setSshPort(?string $sshPort): static
    {
        $this->sshPort = $sshPort;

        return $this;
    }
}
