src/Entity/User.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=UserRepository::class)
  9.  */
  10. class User
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=64)
  20.      */
  21.     private $nom;
  22.     /**
  23.      * @ORM\Column(type="string", length=64)
  24.      */
  25.     private $prenom;
  26.     /**
  27.      * @ORM\Column(type="string", length=128)
  28.      */
  29.     private $email;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $adresse;
  34.     /**
  35.      * @ORM\Column(type="string", length=80)
  36.      */
  37.     private $adresse1;
  38.     /**
  39.      * @ORM\Column(type="string", length=80, nullable=true)
  40.      */
  41.     private $adresse2;
  42.     /**
  43.      * @ORM\Column(type="string", length=5)
  44.      */
  45.     private $code_postal;
  46.     /**
  47.      * @ORM\Column(type="string", length=128)
  48.      */
  49.     private $ville;
  50.     /**
  51.      * @ORM\Column(type="string", length=32)
  52.      */
  53.     private $telephone;
  54.     /**
  55.      * @ORM\Column(type="date")
  56.      */
  57.     private $mise_disposition;
  58.     /**
  59.      * @ORM\Column(type="string", length=128, nullable=true)
  60.      */
  61.     private $nom_professeur;
  62.     /**
  63.      * @ORM\Column(type="string", length=255)
  64.      */
  65.     private $token;
  66.     /**
  67.      * @ORM\OneToMany(targetEntity=Harpe::class, mappedBy="user")
  68.      */
  69.     private $harpes;
  70.     /**
  71.      * @ORM\Column(type="string", length=255, nullable=true)
  72.      */
  73.     private $iban;
  74.     /**
  75.      * @ORM\Column(type="string", length=255, nullable=true)
  76.      */
  77.     private $bic;
  78.     /**
  79.      * @ORM\Column(type="string", length=255, nullable=true)
  80.      */
  81.     private $banque;
  82.     /**
  83.      * @ORM\Column(type="datetime")
  84.      */
  85.     private $date_naissance;
  86.     /**
  87.      * @ORM\Column(type="string", length=255, nullable=true)
  88.      */
  89.     private $lieu_naissance;
  90.     public function __construct()
  91.     {
  92.         $this->harpes = new ArrayCollection();
  93.     }
  94.     public function getId(): ?int
  95.     {
  96.         return $this->id;
  97.     }
  98.     public function getNom(): ?string
  99.     {
  100.         return $this->nom;
  101.     }
  102.     public function setNom(string $nom): self
  103.     {
  104.         $this->nom $nom;
  105.         return $this;
  106.     }
  107.     public function getPrenom(): ?string
  108.     {
  109.         return $this->prenom;
  110.     }
  111.     public function setPrenom(string $prenom): self
  112.     {
  113.         $this->prenom $prenom;
  114.         return $this;
  115.     }
  116.     public function getEmail(): ?string
  117.     {
  118.         return $this->email;
  119.     }
  120.     public function setEmail(string $email): self
  121.     {
  122.         $this->email $email;
  123.         return $this;
  124.     }
  125.     public function getAdresse(): ?string
  126.     {
  127.         return $this->adresse;
  128.     }
  129.     public function setAdresse(string $adresse): self
  130.     {
  131.         $this->adresse $adresse;
  132.         return $this;
  133.     }
  134.     protected function getAdresseLignes() :array {
  135.         return (array) explode(PHP_EOL$this->adresse);
  136.     }
  137.     public function setAdresse1(string $ad1) :self {
  138.         if (strlen(trim($ad1)) > 50) {
  139.             throw new \LengthException('Longueur de 50 caractères maximum.');
  140.         }
  141.         $this->adresse1 trim($ad1);
  142.         $tmp $this->getAdresseLignes();
  143.         $this->adresse $ad1.PHP_EOL;
  144.         $this->adresse .= (isset($tmp[1])) ? $tmp[1] : '';
  145.         return $this;
  146.     }
  147.     public function getAdresse1():string {
  148.         return $this->adresse1;
  149.     }
  150.     public function setAdresse2(?string $ad2) :self {
  151.         if (strlen(trim($ad2)) > 50) {
  152.             throw new \LengthException('Longueur de 50 caractères maximum.');
  153.         }
  154.         $tmp $this->getAdresseLignes();
  155.         $this->adresse $tmp[0].PHP_EOL;
  156.         $this->adresse .= trim($ad2);
  157.         return $this;
  158.     }
  159.     public function getAdresse2() :?string {
  160.         return $this->adresse2;
  161.     }
  162.     public function getCodePostal(): ?string
  163.     {
  164.         return $this->code_postal;
  165.     }
  166.     public function setCodePostal(string $code_postal): self
  167.     {
  168.         $this->code_postal $code_postal;
  169.         return $this;
  170.     }
  171.     public function getVille(): ?string
  172.     {
  173.         return $this->ville;
  174.     }
  175.     public function setVille(string $ville): self
  176.     {
  177.         $this->ville $ville;
  178.         return $this;
  179.     }
  180.     public function getTelephone(): ?string
  181.     {
  182.         return $this->telephone;
  183.     }
  184.     public function setTelephone(string $telephone): self
  185.     {
  186.         $this->telephone $telephone;
  187.         return $this;
  188.     }
  189.     public function getMiseDisposition(): ?\DateTimeInterface
  190.     {
  191.         return $this->mise_disposition;
  192.     }
  193.     public function setMiseDisposition(\DateTimeInterface $mise_disposition): self
  194.     {
  195.         $this->mise_disposition $mise_disposition;
  196.         return $this;
  197.     }
  198.     public function getNomProfesseur(): ?string
  199.     {
  200.         return $this->nom_professeur;
  201.     }
  202.     public function setNomProfesseur(?string $nom_professeur): self
  203.     {
  204.         $this->nom_professeur $nom_professeur;
  205.         return $this;
  206.     }
  207.     public function getToken(): ?string
  208.     {
  209.         return $this->token;
  210.     }
  211.     public function setToken(string $token): self
  212.     {
  213.         $this->token $token;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return Collection|Harpe[]
  218.      */
  219.     public function getHarpes(): Collection
  220.     {
  221.         return $this->harpes;
  222.     }
  223.     public function addHarpe(Harpe $harpe): self
  224.     {
  225.         if (!$this->harpes->contains($harpe)) {
  226.             $this->harpes[] = $harpe;
  227.             $harpe->setUser($this);
  228.         }
  229.         return $this;
  230.     }
  231.     public function removeHarpe(Harpe $harpe): self
  232.     {
  233.         if ($this->harpes->removeElement($harpe)) {
  234.             // set the owning side to null (unless already changed)
  235.             if ($harpe->getUser() === $this) {
  236.                 $harpe->setUser(null);
  237.             }
  238.         }
  239.         return $this;
  240.     }
  241.     public function getIban(): ?string
  242.     {
  243.         return $this->iban;
  244.     }
  245.     public function setIban(?string $iban): self
  246.     {
  247.         $this->iban $iban;
  248.         return $this;
  249.     }
  250.     public function getBic(): ?string
  251.     {
  252.         return $this->bic;
  253.     }
  254.     public function setBic(?string $bic): self
  255.     {
  256.         $this->bic $bic;
  257.         return $this;
  258.     }
  259.     public function getBanque(): ?string
  260.     {
  261.         return $this->banque;
  262.     }
  263.     public function setBanque(?string $b): self
  264.     {
  265.         $this->banque $b;
  266.         return $this;
  267.     }
  268.     public function getDateNaissance(): ?\DateTimeInterface
  269.     {
  270.         return $this->date_naissance;
  271.     }
  272.     public function setDateNaissance(\DateTimeInterface $date_naissance): self
  273.     {
  274.         $this->date_naissance $date_naissance;
  275.         return $this;
  276.     }
  277.     public function getLieuNaissance(): ?string
  278.     {
  279.         return $this->lieu_naissance;
  280.     }
  281.     public function setLieuNaissance(?string $lieu_naissance): self
  282.     {
  283.         $this->lieu_naissance $lieu_naissance;
  284.         return $this;
  285.     }
  286.     public function getFormated() {
  287.         $ret = array();
  288.         $ret[] = strtoupper($this->getNom()).' '.ucwords($this->getPrenom());
  289.         $ret[] = $this->getEmail();
  290.         $ret[] = $this->getTelephone();
  291.         $ret[] = $this->getAdresse().PHP_EOL.$this->getCodePostal().' '.$this->getVille();
  292.         return implode(PHP_EOL$ret);
  293.     }
  294.     /**
  295.      * Formatte un numéro de téléphone au format internationnal
  296.      * (selon specs techniques Monetico)
  297.      * @param string  $num  Numéro de téléphone
  298.      * @return string
  299.      */
  300.     public function phoneIntlFrmt($num) {
  301.         return str_replace(array(' ','-','.'), ''preg_replace('/^(0)([\d -\.]+)/''+33-\2'$num));
  302.     }
  303. }