<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
*/
class User
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=64)
*/
private $nom;
/**
* @ORM\Column(type="string", length=64)
*/
private $prenom;
/**
* @ORM\Column(type="string", length=128)
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
*/
private $adresse;
/**
* @ORM\Column(type="string", length=80)
*/
private $adresse1;
/**
* @ORM\Column(type="string", length=80, nullable=true)
*/
private $adresse2;
/**
* @ORM\Column(type="string", length=5)
*/
private $code_postal;
/**
* @ORM\Column(type="string", length=128)
*/
private $ville;
/**
* @ORM\Column(type="string", length=32)
*/
private $telephone;
/**
* @ORM\Column(type="date")
*/
private $mise_disposition;
/**
* @ORM\Column(type="string", length=128, nullable=true)
*/
private $nom_professeur;
/**
* @ORM\Column(type="string", length=255)
*/
private $token;
/**
* @ORM\OneToMany(targetEntity=Harpe::class, mappedBy="user")
*/
private $harpes;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $iban;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $bic;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $banque;
/**
* @ORM\Column(type="datetime")
*/
private $date_naissance;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lieu_naissance;
public function __construct()
{
$this->harpes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
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 getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(string $adresse): self
{
$this->adresse = $adresse;
return $this;
}
protected function getAdresseLignes() :array {
return (array) explode(PHP_EOL, $this->adresse);
}
public function setAdresse1(string $ad1) :self {
if (strlen(trim($ad1)) > 50) {
throw new \LengthException('Longueur de 50 caractères maximum.');
}
$this->adresse1 = trim($ad1);
$tmp = $this->getAdresseLignes();
$this->adresse = $ad1.PHP_EOL;
$this->adresse .= (isset($tmp[1])) ? $tmp[1] : '';
return $this;
}
public function getAdresse1():string {
return $this->adresse1;
}
public function setAdresse2(?string $ad2) :self {
if (strlen(trim($ad2)) > 50) {
throw new \LengthException('Longueur de 50 caractères maximum.');
}
$tmp = $this->getAdresseLignes();
$this->adresse = $tmp[0].PHP_EOL;
$this->adresse .= trim($ad2);
return $this;
}
public function getAdresse2() :?string {
return $this->adresse2;
}
public function getCodePostal(): ?string
{
return $this->code_postal;
}
public function setCodePostal(string $code_postal): self
{
$this->code_postal = $code_postal;
return $this;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(string $ville): self
{
$this->ville = $ville;
return $this;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function getMiseDisposition(): ?\DateTimeInterface
{
return $this->mise_disposition;
}
public function setMiseDisposition(\DateTimeInterface $mise_disposition): self
{
$this->mise_disposition = $mise_disposition;
return $this;
}
public function getNomProfesseur(): ?string
{
return $this->nom_professeur;
}
public function setNomProfesseur(?string $nom_professeur): self
{
$this->nom_professeur = $nom_professeur;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(string $token): self
{
$this->token = $token;
return $this;
}
/**
* @return Collection|Harpe[]
*/
public function getHarpes(): Collection
{
return $this->harpes;
}
public function addHarpe(Harpe $harpe): self
{
if (!$this->harpes->contains($harpe)) {
$this->harpes[] = $harpe;
$harpe->setUser($this);
}
return $this;
}
public function removeHarpe(Harpe $harpe): self
{
if ($this->harpes->removeElement($harpe)) {
// set the owning side to null (unless already changed)
if ($harpe->getUser() === $this) {
$harpe->setUser(null);
}
}
return $this;
}
public function getIban(): ?string
{
return $this->iban;
}
public function setIban(?string $iban): self
{
$this->iban = $iban;
return $this;
}
public function getBic(): ?string
{
return $this->bic;
}
public function setBic(?string $bic): self
{
$this->bic = $bic;
return $this;
}
public function getBanque(): ?string
{
return $this->banque;
}
public function setBanque(?string $b): self
{
$this->banque = $b;
return $this;
}
public function getDateNaissance(): ?\DateTimeInterface
{
return $this->date_naissance;
}
public function setDateNaissance(\DateTimeInterface $date_naissance): self
{
$this->date_naissance = $date_naissance;
return $this;
}
public function getLieuNaissance(): ?string
{
return $this->lieu_naissance;
}
public function setLieuNaissance(?string $lieu_naissance): self
{
$this->lieu_naissance = $lieu_naissance;
return $this;
}
public function getFormated() {
$ret = array();
$ret[] = strtoupper($this->getNom()).' '.ucwords($this->getPrenom());
$ret[] = $this->getEmail();
$ret[] = $this->getTelephone();
$ret[] = $this->getAdresse().PHP_EOL.$this->getCodePostal().' '.$this->getVille();
return implode(PHP_EOL, $ret);
}
/**
* Formatte un numéro de téléphone au format internationnal
* (selon specs techniques Monetico)
* @param string $num Numéro de téléphone
* @return string
*/
public function phoneIntlFrmt($num) {
return str_replace(array(' ','-','.'), '', preg_replace('/^(0)([\d -\.]+)/', '+33-\2', $num));
}
}