<?php

namespace App\Entity;

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

#[ORM\Entity(repositoryClass: HardwareRepository::class)]
class Hardware extends AbstractEntity
{
    use NameableTrait;

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

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

    #[ORM\ManyToOne]
    private ?HardwareType $type = null;

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

        $this->hardwareProfiles = 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;
    }

    /**
     * @return Collection<int, HardwareProfile>
     */
    public function getHardwareProfiles(): Collection
    {
        return $this->hardwareProfiles;
    }

    public function addHardwareProfile(HardwareProfile $hardwareProfile): static
    {
        if (!$this->hardwareProfiles->contains($hardwareProfile)) {
            $this->hardwareProfiles->add($hardwareProfile);
            $hardwareProfile->addHardwareCollection($this);
        }

        return $this;
    }

    public function removeHardwareProfile(HardwareProfile $hardwareProfile): static
    {
        if ($this->hardwareProfiles->removeElement($hardwareProfile)) {
            $hardwareProfile->removeHardwareCollection($this);
        }

        return $this;
    }

    public function getType(): ?HardwareType
    {
        return $this->type;
    }

    public function setType(?HardwareType $type): static
    {
        $this->type = $type;

        return $this;
    }
}
