<?php

namespace App\Entity;

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

#[ORM\Entity(repositoryClass: HardwareProfileRepository::class)]
class HardwareProfile extends AbstractEntity
{
    #[ORM\Column(length: 255, nullable: true)]
    private ?string $description = null;

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

    #[ORM\ManyToOne(targetEntity: OrganizationalUnit::class)]
    #[ORM\JoinColumn(nullable: false)]
    private ?OrganizationalUnit $organizationalUnit = null;

    /**
     * @var Collection<int, Hardware>
     */
    #[ORM\ManyToMany(targetEntity: Hardware::class, inversedBy: 'hardwareProfiles')]
    private Collection $hardwareCollection;

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

    public function __construct()
    {
        parent::__construct();

        $this->hardwareCollection = new ArrayCollection();
        $this->clients = new ArrayCollection();
    }

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

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(?string $description): static
    {
        $this->description = $description;

        return $this;
    }

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

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

        return $this;
    }

    public function getOrganizationalUnit(): ?OrganizationalUnit
    {
        return $this->organizationalUnit;
    }

    public function setOrganizationalUnit(?OrganizationalUnit $organizationalUnit): static
    {
        $this->organizationalUnit = $organizationalUnit;

        return $this;
    }

    /**
     * @return Collection<int, Hardware>
     */
    public function getHardwareCollection(): Collection
    {
        return $this->hardwareCollection;
    }

    public function addHardwareCollection(Hardware $hardwareCollection): static
    {
        if (!$this->hardwareCollection->contains($hardwareCollection)) {
            $this->hardwareCollection->add($hardwareCollection);
        }

        return $this;
    }

    public function removeHardwareCollection(Hardware $hardwareCollection): static
    {
        $this->hardwareCollection->removeElement($hardwareCollection);

        return $this;
    }

    /**
     * @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->setHardwareProfile($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->getHardwareProfile() === $this) {
                $client->setHardwareProfile(null);
            }
        }

        return $this;
    }
}
