<?php

namespace App\Entity\Properties;

use App\Entity\Properties\Bien;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * @ORM\Entity
 */
class Demarcheur
{
    use \App\Entity\Common\IdTrait;
    use \App\Entity\Common\DatesTrait;

    /**
     * @ORM\Column(type="string", length=100)
     */
    private string $nom;

    /**
     * @ORM\Column(type="string", length=100, nullable=true)
     */
    private ?string $prenom = null;

    /**
     * @ORM\Column(type="string", length=150, nullable=true)
     */
    private ?string $email = null;

    /**
     * @ORM\Column(type="string", length=20, nullable=true)
     */
    private ?string $telephone = null;

    /**
     * @ORM\OneToMany(targetEntity=\App\Entity\Properties\Bien::class, mappedBy="demarcheur")
     */
    private Collection $biens;

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

    // Getters / Setters
    public function getNom(): string
    {
        return $this->nom;
    }
    public function setNom(string $nom): self
    {
        $this->nom = $nom;
        return $this;
    }

    public function getPrenom(): ?string
    {
        return $this->prenom;
    }
    public function setPrenom(?string $prenom): self
    {
        $this->prenom = $prenom;
        return $this;
    }

    public function getEmail(): ?string
    {
        return $this->email;
    }
    public function setEmail(?string $email): self
    {
        $this->email = $email;
        return $this;
    }

    public function getTelephone(): ?string
    {
        return $this->telephone;
    }
    public function setTelephone(?string $telephone): self
    {
        $this->telephone = $telephone;
        return $this;
    }

    public function getBiens(): Collection
    {
        return $this->biens;
    }
    public function addBien(Bien $bien): self
    {
        if (!$this->biens->contains($bien)) {
            $this->biens[] = $bien;
            $bien->setDemarcheur($this);
        }
        return $this;
    }

    public function removeBien(Bien $bien): self
    {
        if ($this->biens->removeElement($bien)) {
            if ($bien->getDemarcheur() === $this) {
                $bien->setDemarcheur(null);
            }
        }
        return $this;
    }
}
