<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Title;
class Person {
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $firstname;
/**
* @var string
*/
private $lastname;
/**
* @var integer
*/
private $sex;
/**
* @var \DateTime
*/
private $birthday;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $titles;
/**
* Constructor
*/
public function __construct() {
$this->titles = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* Set firstname
*
* @param string $firstname
*
* @return Person
*/
public function setFirstname($firstname) {
$this->firstname = $firstname;
return $this;
}
/**
* Get firstname
*
* @return string
*/
public function getFirstname() {
return $this->firstname;
}
/**
* Set lastname
*
* @param string $lastname
*
* @return Person
*/
public function setLastname($lastname) {
$this->lastname = $lastname;
return $this;
}
/**
* Get lastname
*
* @return string
*/
public function getLastname() {
return $this->lastname;
}
/**
* Set sex
*
* @param integer $sex
*
* @return Person
*/
public function setSex($sex) {
$this->sex = $sex;
return $this;
}
/**
* Get sex
*
* @return integer
*/
public function getSex() {
return $this->sex;
}
/**
* Set birthday
*
* @param \DateTime $birthday
*
* @return Person
*/
public function setBirthday($birthday) {
$this->birthday = $birthday;
return $this;
}
/**
* Get birthday
*
* @return \DateTime
*/
public function getBirthday() {
return $this->birthday;
}
/**
* Add title
*
* @param \App\Entity\Title $title
*
* @return Person
*/
public function addTitle(\App\Entity\Title $title) {
$this->titles[] = $title;
return $this;
}
/**
* Remove title
*
* @param \App\Entity\Title $title
*/
public function removeTitle(\App\Entity\Title $title) {
$this->titles->removeElement($title);
}
/**
* Get titles
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getTitles() {
return $this->titles;
}
private function getStringTitlesHonor() {
$strTitles = '';
/* @var $title Title */
foreach ($this->titles as $title) {
if ($title->getTitleType()->getId() == 3) {
$strTitles = $strTitles . ' ' . $title->getShortName();
}
}
return $strTitles;
}
private function getStringTitlesPre() {
$strTitles = '';
/* @var $title Title */
foreach ($this->titles as $title) {
if ($title->getTitleType()->getId() == 1) {
$strTitles = $strTitles . ' ' . $title->getShortName();
}
}
return $strTitles;
}
private function getStringTitlesPost() {
$strTitles = '';
/* @var $title Title */
foreach ($this->titles as $title) {
if ($title->getTitleType()->getId() == 2) {
$strTitles = $strTitles . ' ' . $title->getShortName();
}
}
return $strTitles;
}
public function getName() {
return $this->firstname . ' ' . $this->lastname;
}
public function getFullName() {
$firstName = $this->firstname;
$lastName = $this->lastname;
$strTitlesHonor = $this->getStringTitlesHonor();
$strTitlesPre = $this->getStringTitlesPre();
$strTitlesPost = $this->getStringTitlesPost();
return trim("$strTitlesHonor $strTitlesPre $firstName $lastName $strTitlesPost");
}
public function __toString() {
return $this->firstname . ' ' . $this->lastname;
}
}