<?php

declare(strict_types=1);

namespace App\Entity\Billing;

use ApiPlatform\Metadata\ApiResource;
use App\Entity\Product\IntangibleDiscountDetail;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * TODO: documenter.
 */
#[ApiResource(operations: [])]
#[ORM\Entity]
class FamilyQuotientBand
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private int $id;

    #[ORM\ManyToOne(targetEntity: FamilyQuotientModel::class, cascade: [], inversedBy: 'familyQuotientBands')]
    #[ORM\JoinColumn(nullable: false)]
    protected mixed $familyQuotientModel;

    /** @var Collection<int, FamilyQuotientBandDetail> */
    //    #[ORM\Column(type: 'string')] // TODO: pourquoi c'est là ça?
    #[ORM\OneToMany(targetEntity: FamilyQuotientBandDetail::class, mappedBy: 'familyQuotientBand', cascade: ['persist'], orphanRemoval: true)]
    protected Collection $familyQuotientBandDetails;

    /** @var Collection<int, IntangibleDiscountDetail> */
    #[ORM\OneToMany(targetEntity: IntangibleDiscountDetail::class, mappedBy: 'familyQuotientBand', cascade: [], orphanRemoval: true)]
    protected Collection $intangibleDiscountDetails;

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

    public function setId(int $id): self
    {
        $this->id = $id;

        return $this;
    }

    public function getFamilyQuotientModel(): mixed
    {
        return $this->familyQuotientModel;
    }

    public function setFamilyQuotientModel(mixed $familyQuotientModel): self
    {
        $this->familyQuotientModel = $familyQuotientModel;

        return $this;
    }

    public function getFamilyQuotientBandDetails(): Collection
    {
        return $this->familyQuotientBandDetails;
    }

    public function addFamilyQuotientBandDetail(FamilyQuotientBandDetail $familyQuotientBandDetail): self
    {
        if (!$this->familyQuotientBandDetails->contains($familyQuotientBandDetail)) {
            $this->familyQuotientBandDetails[] = $familyQuotientBandDetail;
            $familyQuotientBandDetail->setFamilyQuotientBand($this);
        }

        return $this;
    }

    public function removeFamilyQuotientBandDetail(FamilyQuotientBandDetail $familyQuotientBandDetail): self
    {
        if ($this->familyQuotientBandDetails->removeElement($familyQuotientBandDetail)) {
            $familyQuotientBandDetail->setFamilyQuotientBand(null);
        }

        return $this;
    }

    public function getIntangibleDiscountDetails(): Collection
    {
        return $this->intangibleDiscountDetails;
    }

    public function addIntangibleDiscountDetail(IntangibleDiscountDetail $intangibleDiscountDetail): self
    {
        if (!$this->intangibleDiscountDetails->contains($intangibleDiscountDetail)) {
            $this->intangibleDiscountDetails[] = $intangibleDiscountDetail;
            $intangibleDiscountDetail->setFamilyQuotientBand($this);
        }

        return $this;
    }

    public function removeIntangibleDiscountDetail(IntangibleDiscountDetail $intangibleDiscountDetail): self
    {
        $this->intangibleDiscountDetails->removeElement($intangibleDiscountDetail);

        return $this;
    }
}
