<?php

namespace App\Entity;

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

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

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

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

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

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


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

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

        return $this;
    }

    /**
     * @return Collection<int, SoftwareProfile>
     */
    public function getSoftwareProfiles(): Collection
    {
        return $this->softwareProfiles;
    }

    public function addSoftwareProfile(SoftwareProfile $softwareProfile): static
    {
        if (!$this->softwareProfiles->contains($softwareProfile)) {
            $this->softwareProfiles->add($softwareProfile);
            $softwareProfile->addSoftwareCollection($this);
        }

        return $this;
    }

    public function removeSoftwareProfile(SoftwareProfile $softwareProfile): static
    {
        if ($this->softwareProfiles->removeElement($softwareProfile)) {
            $softwareProfile->removeSoftwareCollection($this);
        }

        return $this;
    }

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

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

        return $this;
    }
}
