<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Auteur
*
* @ORM\Table(name="auteur")
* @ORM\Entity(repositoryClass="App\Repository\AuteurRepository")
*/
class Auteur
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=255)
*/
private $nom;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set nom
*
* @param string $nom
*
* @return Auteur
*/
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
/**
* Get nom
*
* @return string
*/
public function getNom()
{
return $this->nom;
}
/**
* Get nom complet (alias pour compatibilité)
*
* @return string
*/
public function getNomComplet()
{
return $this->nom;
}
/**
* Get initiale (première lettre du nom, sans accent)
*
* @return string
*/
public function getInitiale()
{
$firstChar = mb_substr($this->nom, 0, 1);
return strtoupper(self::removeAccents($firstChar));
}
/**
* Supprime les accents d'une chaîne
*/
public static function removeAccents($string)
{
$accents = ['À','Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ò','Ó','Ô','Õ','Ö','Ù','Ú','Û','Ü','Ý','à','á','â','ã','ä','å','ç','è','é','ê','ë','ì','í','î','ï','ð','ò','ó','ô','õ','ö','ù','ú','û','ü','ý','ÿ'];
$sans = ['A','A','A','A','A','A','C','E','E','E','E','I','I','I','I','O','O','O','O','O','U','U','U','U','Y','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','o','o','o','o','o','o','u','u','u','u','y','y'];
return str_replace($accents, $sans, $string);
}
}