<?php

declare (strict_types = 1);

namespace MyApp\Entity;
use MyApp\Entity\role;

class Compte
{
    private ?int $id = null; // vide tant qu'il n'a pas récup de valeur de la BDD
    private string $nom;
    private string $prenom;
    private string $num_telephone;
    private string $mail;
    private string $mot_de_passe;
    private ?role $id_role;

    public function __construct(?int $id, string $nom, string $prenom, string $num_telephone, string $mail, string $mot_de_passe, ?role $id_role)
    {
        $this->id = $id;
        $this->nom = $nom;
        $this->prenom = $prenom;
        $this->num_telephone = $num_telephone;
        $this->mail = $mail;
        $this->mot_de_passe = $mot_de_passe;
        $this->id_role = $id_role;
    }

    // get pour récuperer des données dans la BDD
    public function getId(): ?int
    {
        return $this->id;
    }
    public function setId(?int $id): void
    {
        $this->id = $id;
    }

    public function getNom(): string
    {
        return $this->nom;
    }
    public function setNom(string $nom): void
    {
        $this->nom = $nom;
    }

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

    public function getNum_telephone(): string
    {
        return $this->num_telephone;
    }
    public function setNum_telephone(string $num_telephone): void
    {
        $this->num_telephone = $num_telephone;
    }

    public function getMail(): string
    {
        return $this->mail;
    }
    
    public function setMail(string $mail): void
    {
        if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
            throw new InvalidArgumentException("Mail invalide.");
        }
        $this->mail = $mail;
    }

    public function getMot_de_passe(): string
    {
        return $this->mot_de_passe;
    }
    public function setMot_de_passe(string $mot_de_passe): void
    {
        $this->mot_de_passe = $mot_de_passe;
    }

    public function verifyMot_de_passe(string $mot_de_passe): bool
    {
        return password_verify($mot_de_passe, $this->mot_de_passe);
    }

    public function getId_role(): ?role
    {
        return $this->id_role;
    }
    public function setId_role(?role $id_role): void
    {
        $this->id_role = $id_role;
    }

}
