<?php

namespace App\Entity;

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

#[ORM\Entity(repositoryClass: ClasseurFractalRepository::class)]
class ClasseurFractal
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;
    #[ORM\Column(length:255, nullable:true)]
    private ?string $name = "";

    #[ORM\OneToMany(mappedBy: 'classeurFractal', targetEntity: CarteFractal::class)]
    private Collection $cartesfractal;

    #[ORM\ManyToOne(inversedBy: 'classeursFractal')]
    private ?MembreFractal $membreFractal = null;
   


    public function __construct()
    {
        $this->cartesfractal = new ArrayCollection();
    }

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

    /**
     * @return Collection<int, CarteFractal>
     */
    public function getCartesfractal(): Collection
    {
        return $this->cartesfractal;
    }
    public function setName(?string $name): void
    {
        $this->name=$name;
    }
    public function addCartesfractal(CarteFractal $cartesfractal): static
    {
        if (!$this->cartesfractal->contains($cartesfractal)) {
            $this->cartesfractal->add($cartesfractal);
            $cartesfractal->setClasseurFractal($this);
        }
        return $this;
    }

    public function removeCartesfractal(CarteFractal $cartesfractal): static
    {
        if ($this->cartesfractal->removeElement($cartesfractal)) {
            // set the owning side to null (unless already changed)
            if ($cartesfractal->getClasseurFractal() == $this) {
                $cartesfractal->setClasseurFractal(null);
            }
        }

        return $this;
    }
    public function getMembrefractal(): ?MembreFractal
    {
        return $this->membreFractal;
    }
    public function setMembreFractal(?MembreFractal $membre): void
    {
        $this->membreFractal=$membre;
    }
    public function __toString(): string
    {
        return $this->name;
    }
}