src/Entity/Auteur.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * Auteur
  6. *
  7. * @ORM\Table(name="auteur")
  8. * @ORM\Entity(repositoryClass="App\Repository\AuteurRepository")
  9. */
  10. class Auteur
  11. {
  12. /**
  13. * @var int
  14. *
  15. * @ORM\Column(name="id", type="integer")
  16. * @ORM\Id
  17. * @ORM\GeneratedValue(strategy="AUTO")
  18. */
  19. private $id;
  20. /**
  21. * @var string
  22. *
  23. * @ORM\Column(name="nom", type="string", length=255)
  24. */
  25. private $nom;
  26. /**
  27. * Get id
  28. *
  29. * @return int
  30. */
  31. public function getId()
  32. {
  33. return $this->id;
  34. }
  35. /**
  36. * Set nom
  37. *
  38. * @param string $nom
  39. *
  40. * @return Auteur
  41. */
  42. public function setNom($nom)
  43. {
  44. $this->nom = $nom;
  45. return $this;
  46. }
  47. /**
  48. * Get nom
  49. *
  50. * @return string
  51. */
  52. public function getNom()
  53. {
  54. return $this->nom;
  55. }
  56. /**
  57. * Get nom complet (alias pour compatibilité)
  58. *
  59. * @return string
  60. */
  61. public function getNomComplet()
  62. {
  63. return $this->nom;
  64. }
  65. /**
  66. * Get initiale (première lettre du nom, sans accent)
  67. *
  68. * @return string
  69. */
  70. public function getInitiale()
  71. {
  72. $firstChar = mb_substr($this->nom, 0, 1);
  73. return strtoupper(self::removeAccents($firstChar));
  74. }
  75. /**
  76. * Supprime les accents d'une chaîne
  77. */
  78. public static function removeAccents($string)
  79. {
  80. $accents = ['À','Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ò','Ó','Ô','Õ','Ö','Ù','Ú','Û','Ü','Ý','à','á','â','ã','ä','å','ç','è','é','ê','ë','ì','í','î','ï','ð','ò','ó','ô','õ','ö','ù','ú','û','ü','ý','ÿ'];
  81. $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'];
  82. return str_replace($accents, $sans, $string);
  83. }
  84. }