<?php
namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use IntlDateFormatter;
/**
* Authcomp
*
* @ORM\Table(
* name="authcomp",
* uniqueConstraints={@ORM\UniqueConstraint(name="Name", columns={"LastName","FirstName","MiddleName"})}
* )
* @ORM\Entity(repositoryClass="App\Repository\AuthcompRepository")
*/
class Authcomp
{
/**
* @var int
*
* @ORM\Column(type="integer", name="ID")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private int $id = 0;
/**
* @var string|null
*
* @ORM\Column(type="string", length=125, nullable=true, name="FullName", updatable=false, insertable=false)
*/
private ?string $fullname;
/**
* @var string|null
*
* @ORM\Column(type="string", length=50, nullable=true, name="FirstName")
*/
private ?string $firstname;
/**
* @var string|null
*
* @ORM\Column(type="string", length=50, nullable=true, name="MiddleName")
*/
private ?string $middlename;
/**
* @var string
*
* @ORM\Column(type="string", length=50, nullable=false, name="LastName")
*/
private string $lastname = '';
/**
* @var string|null
*
* @ORM\Column(type="string", length=5, nullable=true, name="Suffix")
*/
private ?string $suffix;
/**
* @var int|null
*
* @ORM\Column(type="integer", nullable=true, name="BirthYYYY")
*/
private ?int $birthyyyy;
/**
* @var int|null
*
* @ORM\Column(type="integer", nullable=true, name="BirthMM")
*/
private ?int $birthmm;
/**
* @var int|null
*
* @ORM\Column(type="integer", nullable=true, name="BirthDD")
*/
private ?int $birthdd;
/**
* @var int|null
*
* @ORM\Column(type="integer", nullable=true, name="DeathYYYY")
*/
private ?int $deathyyyy;
/**
* @var int|null
*
* @ORM\Column(type="integer", nullable=true, name="DeathMM")
*/
private ?int $deathmm;
/**
* @var int|null
*
* @ORM\Column(type="integer", nullable=true, name="DeathDD")
*/
private ?int $deathdd;
/**
* @var string|null
*
* @ORM\Column(type="text", length=65535, nullable=true, name="Notes")
*/
private ?string $notes;
/**
* @var string|null
*
* @ORM\Column(type="string", length=150, nullable=true, name="PictureCredits")
*/
private ?string $picturecredits;
/**
* @var string|null
*/
private ?string $birthDate;
/**
* @var string|null
*/
private ?string $deathDate;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Hymns", mappedBy="author")
* @ORM\JoinColumn(nullable=true, referencedColumnName="id")
*/
private Collection $auth_hymns;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Hymns", mappedBy="composer")
* @ORM\JoinColumn(nullable=true, referencedColumnName="id")
*/
private Collection $comp_hymns;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Hymns", mappedBy="arranger")
* @ORM\JoinColumn(nullable=true, referencedColumnName="id")
*/
private Collection $arr_hymns;
/**
* Authcomp constructor.
*/
public function __construct()
{
$this->setBirthDate();
$this->setDeathDate();
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id ?? null;
}
/**
* @return string|null
*/
public function getFullname(): ?string
{
return $this->fullname ?? null;
}
/**
* @param string|null $fullname
*
* @return $this
*/
public function setFullname(?string $fullname): self
{
$this->fullname = $fullname;
return $this;
}
/**
* @return string|null
*/
public function getFirstname(): ?string
{
return $this->firstname ?? null;
}
/**
* @param string|null $firstname
*
* @return $this
*/
public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
/**
* @return string|null
*/
public function getMiddlename(): ?string
{
return $this->middlename ?? null;
}
/**
* @param string|null $middlename
*
* @return $this
*/
public function setMiddlename(?string $middlename): self
{
$this->middlename = $middlename;
return $this;
}
/**
* @return string|null
*/
public function getLastname(): ?string
{
return $this->lastname ?? null;
}
/**
* @param string $lastname
*
* @return $this
*/
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
/**
* @return string|null
*/
public function getSuffix(): ?string
{
return $this->suffix ?? null;
}
/**
* @param string|null $suffix
*
* @return $this
*/
public function setSuffix(?string $suffix): self
{
$this->suffix = $suffix;
return $this;
}
/**
* @return int|null
*/
public function getBirthyyyy(): ?int
{
return $this->birthyyyy ?? null;
}
/**
* @param int|null $birthyyyy
*
* @return $this
*/
public function setBirthyyyy(?int $birthyyyy): self
{
$this->birthyyyy = $birthyyyy;
return $this;
}
/**
* @return int|null
*/
public function getBirthmm(): ?int
{
return $this->birthmm ?? null;
}
/**
* @param int|null $birthmm
*
* @return $this
*/
public function setBirthmm(?int $birthmm): self
{
$this->birthmm = $birthmm;
return $this;
}
/**
* @return int|null
*/
public function getBirthdd(): ?int
{
return $this->birthdd ?? null;
}
/**
* @param int|null $birthdd
*
* @return $this
*/
public function setBirthdd(?int $birthdd): self
{
$this->birthdd = $birthdd;
return $this;
}
/**
* @return int|null
*/
public function getDeathyyyy(): ?int
{
return $this->deathyyyy ?? null;
}
/**
* @param int|null $deathyyyy
*
* @return $this
*/
public function setDeathyyyy(?int $deathyyyy): self
{
$this->deathyyyy = $deathyyyy;
return $this;
}
/**
* @return int|null
*/
public function getDeathmm(): ?int
{
return $this->deathmm ?? null;
}
/**
* @param int|null $deathmm
*
* @return $this
*/
public function setDeathmm(?int $deathmm): self
{
$this->deathmm = $deathmm;
return $this;
}
/**
* @return int|null
*/
public function getDeathdd(): ?int
{
return $this->deathdd ?? null;
}
/**
* @param int|null $deathdd
*
* @return $this
*/
public function setDeathdd(?int $deathdd): self
{
$this->deathdd = $deathdd;
return $this;
}
/**
* @return string|null
*/
public function getNotes(): ?string
{
return $this->notes ?? null;
}
/**
* @param string|null $notes
*
* @return $this
*/
public function setNotes(?string $notes): self
{
$this->notes = $notes;
return $this;
}
/**
* @return string|null
*/
public function getPicturecredits(): ?string
{
return $this->picturecredits ?? null;
}
/**
* @param string|null $picturecredits
*
* @return $this
*/
public function setPicturecredits(?string $picturecredits): self
{
$this->picturecredits = $picturecredits;
return $this;
}
/**
* @return string|null
*/
public function getBirthDate(): ?string
{
$this->setBirthDate();
return $this->birthDate;
}
/**
* @return void
*/
public function setBirthDate(): void
{
$byyyy = (string) $this->getBirthyyyy();
if ($byyyy === '') {
$this->birthDate = 'Unknown';
} else if (strlen($byyyy) >= 1 && $this->getBirthmm() === null) {
$this->birthDate = $byyyy;
} else {
$fmt = new IntlDateFormatter(
'en_US', // Your locale?
IntlDateFormatter::FULL,
IntlDateFormatter::NONE,
'America/Detroit',
IntlDateFormatter::GREGORIAN
);
$date = new DateTime();
$date->setDate((int)$this->getBirthyyyy(), (int)$this->getBirthmm(), (int)$this->getBirthdd());
$this->birthDate = $fmt->format($date);
}
}
/**
* @return string|null
*/
public function getDeathDate(): ?string
{
$this->setDeathDate();
return $this->deathDate;
}
/**
* @return void
*/
public function setDeathDate(): void
{
$dyyyy = (string) $this->getDeathyyyy();
if ($dyyyy === '') {
$this->deathDate = 'Unknown';
} else if (strlen($dyyyy) >= 1 && $this->getDeathmm() === null) {
$this->deathDate = $dyyyy;
} else {
$fmt = new IntlDateFormatter(
'en_US', // Your locale?
IntlDateFormatter::FULL,
IntlDateFormatter::NONE,
'America/Detroit',
IntlDateFormatter::GREGORIAN
);
$date = new DateTime();
$date->setDate((int)$this->getDeathyyyy(), (int)$this->getDeathmm(), (int)$this->getDeathdd());
$this->deathDate = $fmt->format($date);
}
}
/**
* @return Collection
*/
public function getAuthHymns(): Collection
{
return $this->auth_hymns;
}
/**
* @param Hymns $hymn
*
* @return $this
*/
public function addAuthHymn(Hymns $hymn): self
{
if (! $this->auth_hymns->contains($hymn)) {
$this->auth_hymns[] = $hymn;
$hymn->setAuthor($this);
}
return $this;
}
/**
* @param Hymns $hymn
*
* @return $this
*/
public function removeAuthHymn(Hymns $hymn): self
{
if ($this->auth_hymns->contains($hymn)) {
$this->auth_hymns->removeElement($hymn);
// set the owning side to null (unless already changed)
if ($hymn->getAuthor() === $this) {
$hymn->setAuthor(null);
}
}
return $this;
}
/**
* @return Collection
*/
public function getCompHymns(): Collection
{
return $this->comp_hymns;
}
/**
* @param Hymns $hymn
*
* @return $this
*/
public function addCompHymn(Hymns $hymn): self
{
if (! $this->comp_hymns->contains($hymn)) {
$this->comp_hymns[] = $hymn;
$hymn->setComposer($this);
}
return $this;
}
/**
* @param Hymns $hymn
*
* @return $this
*/
public function removeCompHymn(Hymns $hymn): self
{
if ($this->comp_hymns->contains($hymn)) {
$this->comp_hymns->removeElement($hymn);
// set the owning side to null (unless already changed)
if ($hymn->getComposer() === $this) {
$hymn->setComposer(null);
}
}
return $this;
}
/**
* @return Collection
*/
public function getArrHymns(): Collection
{
return $this->arr_hymns;
}
/**
* @param Hymns $arrHymn
*
* @return $this
*/
public function addArrHymn(Hymns $arrHymn): self
{
if (! $this->arr_hymns->contains($arrHymn)) {
$this->arr_hymns[] = $arrHymn;
$arrHymn->setArranger($this);
}
return $this;
}
/**
* @param Hymns $arrHymn
*
* @return $this
*/
public function removeArrHymn(Hymns $arrHymn): self
{
if ($this->arr_hymns->contains($arrHymn)) {
$this->arr_hymns->removeElement($arrHymn);
// set the owning side to null (unless already changed)
if ($arrHymn->getArranger() === $this) {
$arrHymn->setArranger(null);
}
}
return $this;
}
/**
* @return string
*/
public function __toString()
{
return (string) $this->getFullname();
}
}