<?php

namespace App\Entity;

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

#[ORM\Entity(repositoryClass: CollectionFractalRepository::class)]
class CollectionFractal
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\ManyToMany(targetEntity: CarteFractal::class)]
    private Collection $cartesFractal;

    #[ORM\ManyToOne(inversedBy: 'collectionsFractal')]
    #[ORM\JoinColumn(nullable: false)]
    private ?MembreFractal $membrefractal = null;

    #[ORM\Column]
    private ?bool $ispublic = null;

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

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

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

    /**
     * @return Collection<int, CarteFractal>
     */
    public function getCartesFractal(): Collection
    {
        return $this->cartesFractal;
    }

    public function addCartesFractal(CarteFractal $collectionFractal): static
    {
        if (!$this->cartesFractal->contains($collectionFractal)) {
            $this->cartesFractal->add($collectionFractal);
        }

        return $this;
    }

    public function removeCartesFractal(CarteFractal $collectionFractal): static
    {
        $this->cartesFractal->removeElement($collectionFractal);

        return $this;
    }

    public function getMembrefractal(): ?MembreFractal
    {
        return $this->membrefractal;
    }

    public function setMembrefractal(?MembreFractal $membrefractal): static
    {
        $this->membrefractal = $membrefractal;

        return $this;
    }

    public function isIspublic(): ?bool
    {
        return $this->ispublic;
    }

    public function setIspublic(bool $ispublic): static
    {
        $this->ispublic = $ispublic;

        return $this;
    }

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

    public function setName(string $name): static
    {
        $this->name = $name;

        return $this;
    }
    public function __toString(): string
    {
        return $this->getName();
    }
}
