src/Entity/Authcomp.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use IntlDateFormatter;
  7. /**
  8. * Authcomp
  9. *
  10. * @ORM\Table(
  11. * name="authcomp",
  12. * uniqueConstraints={@ORM\UniqueConstraint(name="Name", columns={"LastName","FirstName","MiddleName"})}
  13. * )
  14. * @ORM\Entity(repositoryClass="App\Repository\AuthcompRepository")
  15. */
  16. class Authcomp
  17. {
  18. /**
  19. * @var int
  20. *
  21. * @ORM\Column(type="integer", name="ID")
  22. * @ORM\Id
  23. * @ORM\GeneratedValue(strategy="IDENTITY")
  24. */
  25. private int $id = 0;
  26. /**
  27. * @var string|null
  28. *
  29. * @ORM\Column(type="string", length=125, nullable=true, name="FullName", updatable=false, insertable=false)
  30. */
  31. private ?string $fullname;
  32. /**
  33. * @var string|null
  34. *
  35. * @ORM\Column(type="string", length=50, nullable=true, name="FirstName")
  36. */
  37. private ?string $firstname;
  38. /**
  39. * @var string|null
  40. *
  41. * @ORM\Column(type="string", length=50, nullable=true, name="MiddleName")
  42. */
  43. private ?string $middlename;
  44. /**
  45. * @var string
  46. *
  47. * @ORM\Column(type="string", length=50, nullable=false, name="LastName")
  48. */
  49. private string $lastname = '';
  50. /**
  51. * @var string|null
  52. *
  53. * @ORM\Column(type="string", length=5, nullable=true, name="Suffix")
  54. */
  55. private ?string $suffix;
  56. /**
  57. * @var int|null
  58. *
  59. * @ORM\Column(type="integer", nullable=true, name="BirthYYYY")
  60. */
  61. private ?int $birthyyyy;
  62. /**
  63. * @var int|null
  64. *
  65. * @ORM\Column(type="integer", nullable=true, name="BirthMM")
  66. */
  67. private ?int $birthmm;
  68. /**
  69. * @var int|null
  70. *
  71. * @ORM\Column(type="integer", nullable=true, name="BirthDD")
  72. */
  73. private ?int $birthdd;
  74. /**
  75. * @var int|null
  76. *
  77. * @ORM\Column(type="integer", nullable=true, name="DeathYYYY")
  78. */
  79. private ?int $deathyyyy;
  80. /**
  81. * @var int|null
  82. *
  83. * @ORM\Column(type="integer", nullable=true, name="DeathMM")
  84. */
  85. private ?int $deathmm;
  86. /**
  87. * @var int|null
  88. *
  89. * @ORM\Column(type="integer", nullable=true, name="DeathDD")
  90. */
  91. private ?int $deathdd;
  92. /**
  93. * @var string|null
  94. *
  95. * @ORM\Column(type="text", length=65535, nullable=true, name="Notes")
  96. */
  97. private ?string $notes;
  98. /**
  99. * @var string|null
  100. *
  101. * @ORM\Column(type="string", length=150, nullable=true, name="PictureCredits")
  102. */
  103. private ?string $picturecredits;
  104. /**
  105. * @var string|null
  106. */
  107. private ?string $birthDate;
  108. /**
  109. * @var string|null
  110. */
  111. private ?string $deathDate;
  112. /**
  113. * @ORM\OneToMany(targetEntity="App\Entity\Hymns", mappedBy="author")
  114. * @ORM\JoinColumn(nullable=true, referencedColumnName="id")
  115. */
  116. private Collection $auth_hymns;
  117. /**
  118. * @ORM\OneToMany(targetEntity="App\Entity\Hymns", mappedBy="composer")
  119. * @ORM\JoinColumn(nullable=true, referencedColumnName="id")
  120. */
  121. private Collection $comp_hymns;
  122. /**
  123. * @ORM\OneToMany(targetEntity="App\Entity\Hymns", mappedBy="arranger")
  124. * @ORM\JoinColumn(nullable=true, referencedColumnName="id")
  125. */
  126. private Collection $arr_hymns;
  127. /**
  128. * Authcomp constructor.
  129. */
  130. public function __construct()
  131. {
  132. $this->setBirthDate();
  133. $this->setDeathDate();
  134. }
  135. /**
  136. * @return int|null
  137. */
  138. public function getId(): ?int
  139. {
  140. return $this->id ?? null;
  141. }
  142. /**
  143. * @return string|null
  144. */
  145. public function getFullname(): ?string
  146. {
  147. return $this->fullname ?? null;
  148. }
  149. /**
  150. * @param string|null $fullname
  151. *
  152. * @return $this
  153. */
  154. public function setFullname(?string $fullname): self
  155. {
  156. $this->fullname = $fullname;
  157. return $this;
  158. }
  159. /**
  160. * @return string|null
  161. */
  162. public function getFirstname(): ?string
  163. {
  164. return $this->firstname ?? null;
  165. }
  166. /**
  167. * @param string|null $firstname
  168. *
  169. * @return $this
  170. */
  171. public function setFirstname(?string $firstname): self
  172. {
  173. $this->firstname = $firstname;
  174. return $this;
  175. }
  176. /**
  177. * @return string|null
  178. */
  179. public function getMiddlename(): ?string
  180. {
  181. return $this->middlename ?? null;
  182. }
  183. /**
  184. * @param string|null $middlename
  185. *
  186. * @return $this
  187. */
  188. public function setMiddlename(?string $middlename): self
  189. {
  190. $this->middlename = $middlename;
  191. return $this;
  192. }
  193. /**
  194. * @return string|null
  195. */
  196. public function getLastname(): ?string
  197. {
  198. return $this->lastname ?? null;
  199. }
  200. /**
  201. * @param string $lastname
  202. *
  203. * @return $this
  204. */
  205. public function setLastname(string $lastname): self
  206. {
  207. $this->lastname = $lastname;
  208. return $this;
  209. }
  210. /**
  211. * @return string|null
  212. */
  213. public function getSuffix(): ?string
  214. {
  215. return $this->suffix ?? null;
  216. }
  217. /**
  218. * @param string|null $suffix
  219. *
  220. * @return $this
  221. */
  222. public function setSuffix(?string $suffix): self
  223. {
  224. $this->suffix = $suffix;
  225. return $this;
  226. }
  227. /**
  228. * @return int|null
  229. */
  230. public function getBirthyyyy(): ?int
  231. {
  232. return $this->birthyyyy ?? null;
  233. }
  234. /**
  235. * @param int|null $birthyyyy
  236. *
  237. * @return $this
  238. */
  239. public function setBirthyyyy(?int $birthyyyy): self
  240. {
  241. $this->birthyyyy = $birthyyyy;
  242. return $this;
  243. }
  244. /**
  245. * @return int|null
  246. */
  247. public function getBirthmm(): ?int
  248. {
  249. return $this->birthmm ?? null;
  250. }
  251. /**
  252. * @param int|null $birthmm
  253. *
  254. * @return $this
  255. */
  256. public function setBirthmm(?int $birthmm): self
  257. {
  258. $this->birthmm = $birthmm;
  259. return $this;
  260. }
  261. /**
  262. * @return int|null
  263. */
  264. public function getBirthdd(): ?int
  265. {
  266. return $this->birthdd ?? null;
  267. }
  268. /**
  269. * @param int|null $birthdd
  270. *
  271. * @return $this
  272. */
  273. public function setBirthdd(?int $birthdd): self
  274. {
  275. $this->birthdd = $birthdd;
  276. return $this;
  277. }
  278. /**
  279. * @return int|null
  280. */
  281. public function getDeathyyyy(): ?int
  282. {
  283. return $this->deathyyyy ?? null;
  284. }
  285. /**
  286. * @param int|null $deathyyyy
  287. *
  288. * @return $this
  289. */
  290. public function setDeathyyyy(?int $deathyyyy): self
  291. {
  292. $this->deathyyyy = $deathyyyy;
  293. return $this;
  294. }
  295. /**
  296. * @return int|null
  297. */
  298. public function getDeathmm(): ?int
  299. {
  300. return $this->deathmm ?? null;
  301. }
  302. /**
  303. * @param int|null $deathmm
  304. *
  305. * @return $this
  306. */
  307. public function setDeathmm(?int $deathmm): self
  308. {
  309. $this->deathmm = $deathmm;
  310. return $this;
  311. }
  312. /**
  313. * @return int|null
  314. */
  315. public function getDeathdd(): ?int
  316. {
  317. return $this->deathdd ?? null;
  318. }
  319. /**
  320. * @param int|null $deathdd
  321. *
  322. * @return $this
  323. */
  324. public function setDeathdd(?int $deathdd): self
  325. {
  326. $this->deathdd = $deathdd;
  327. return $this;
  328. }
  329. /**
  330. * @return string|null
  331. */
  332. public function getNotes(): ?string
  333. {
  334. return $this->notes ?? null;
  335. }
  336. /**
  337. * @param string|null $notes
  338. *
  339. * @return $this
  340. */
  341. public function setNotes(?string $notes): self
  342. {
  343. $this->notes = $notes;
  344. return $this;
  345. }
  346. /**
  347. * @return string|null
  348. */
  349. public function getPicturecredits(): ?string
  350. {
  351. return $this->picturecredits ?? null;
  352. }
  353. /**
  354. * @param string|null $picturecredits
  355. *
  356. * @return $this
  357. */
  358. public function setPicturecredits(?string $picturecredits): self
  359. {
  360. $this->picturecredits = $picturecredits;
  361. return $this;
  362. }
  363. /**
  364. * @return string|null
  365. */
  366. public function getBirthDate(): ?string
  367. {
  368. $this->setBirthDate();
  369. return $this->birthDate;
  370. }
  371. /**
  372. * @return void
  373. */
  374. public function setBirthDate(): void
  375. {
  376. $byyyy = (string) $this->getBirthyyyy();
  377. if ($byyyy === '') {
  378. $this->birthDate = 'Unknown';
  379. } else if (strlen($byyyy) >= 1 && $this->getBirthmm() === null) {
  380. $this->birthDate = $byyyy;
  381. } else {
  382. $fmt = new IntlDateFormatter(
  383. 'en_US', // Your locale?
  384. IntlDateFormatter::FULL,
  385. IntlDateFormatter::NONE,
  386. 'America/Detroit',
  387. IntlDateFormatter::GREGORIAN
  388. );
  389. $date = new DateTime();
  390. $date->setDate((int)$this->getBirthyyyy(), (int)$this->getBirthmm(), (int)$this->getBirthdd());
  391. $this->birthDate = $fmt->format($date);
  392. }
  393. }
  394. /**
  395. * @return string|null
  396. */
  397. public function getDeathDate(): ?string
  398. {
  399. $this->setDeathDate();
  400. return $this->deathDate;
  401. }
  402. /**
  403. * @return void
  404. */
  405. public function setDeathDate(): void
  406. {
  407. $dyyyy = (string) $this->getDeathyyyy();
  408. if ($dyyyy === '') {
  409. $this->deathDate = 'Unknown';
  410. } else if (strlen($dyyyy) >= 1 && $this->getDeathmm() === null) {
  411. $this->deathDate = $dyyyy;
  412. } else {
  413. $fmt = new IntlDateFormatter(
  414. 'en_US', // Your locale?
  415. IntlDateFormatter::FULL,
  416. IntlDateFormatter::NONE,
  417. 'America/Detroit',
  418. IntlDateFormatter::GREGORIAN
  419. );
  420. $date = new DateTime();
  421. $date->setDate((int)$this->getDeathyyyy(), (int)$this->getDeathmm(), (int)$this->getDeathdd());
  422. $this->deathDate = $fmt->format($date);
  423. }
  424. }
  425. /**
  426. * @return Collection
  427. */
  428. public function getAuthHymns(): Collection
  429. {
  430. return $this->auth_hymns;
  431. }
  432. /**
  433. * @param Hymns $hymn
  434. *
  435. * @return $this
  436. */
  437. public function addAuthHymn(Hymns $hymn): self
  438. {
  439. if (! $this->auth_hymns->contains($hymn)) {
  440. $this->auth_hymns[] = $hymn;
  441. $hymn->setAuthor($this);
  442. }
  443. return $this;
  444. }
  445. /**
  446. * @param Hymns $hymn
  447. *
  448. * @return $this
  449. */
  450. public function removeAuthHymn(Hymns $hymn): self
  451. {
  452. if ($this->auth_hymns->contains($hymn)) {
  453. $this->auth_hymns->removeElement($hymn);
  454. // set the owning side to null (unless already changed)
  455. if ($hymn->getAuthor() === $this) {
  456. $hymn->setAuthor(null);
  457. }
  458. }
  459. return $this;
  460. }
  461. /**
  462. * @return Collection
  463. */
  464. public function getCompHymns(): Collection
  465. {
  466. return $this->comp_hymns;
  467. }
  468. /**
  469. * @param Hymns $hymn
  470. *
  471. * @return $this
  472. */
  473. public function addCompHymn(Hymns $hymn): self
  474. {
  475. if (! $this->comp_hymns->contains($hymn)) {
  476. $this->comp_hymns[] = $hymn;
  477. $hymn->setComposer($this);
  478. }
  479. return $this;
  480. }
  481. /**
  482. * @param Hymns $hymn
  483. *
  484. * @return $this
  485. */
  486. public function removeCompHymn(Hymns $hymn): self
  487. {
  488. if ($this->comp_hymns->contains($hymn)) {
  489. $this->comp_hymns->removeElement($hymn);
  490. // set the owning side to null (unless already changed)
  491. if ($hymn->getComposer() === $this) {
  492. $hymn->setComposer(null);
  493. }
  494. }
  495. return $this;
  496. }
  497. /**
  498. * @return Collection
  499. */
  500. public function getArrHymns(): Collection
  501. {
  502. return $this->arr_hymns;
  503. }
  504. /**
  505. * @param Hymns $arrHymn
  506. *
  507. * @return $this
  508. */
  509. public function addArrHymn(Hymns $arrHymn): self
  510. {
  511. if (! $this->arr_hymns->contains($arrHymn)) {
  512. $this->arr_hymns[] = $arrHymn;
  513. $arrHymn->setArranger($this);
  514. }
  515. return $this;
  516. }
  517. /**
  518. * @param Hymns $arrHymn
  519. *
  520. * @return $this
  521. */
  522. public function removeArrHymn(Hymns $arrHymn): self
  523. {
  524. if ($this->arr_hymns->contains($arrHymn)) {
  525. $this->arr_hymns->removeElement($arrHymn);
  526. // set the owning side to null (unless already changed)
  527. if ($arrHymn->getArranger() === $this) {
  528. $arrHymn->setArranger(null);
  529. }
  530. }
  531. return $this;
  532. }
  533. /**
  534. * @return string
  535. */
  536. public function __toString()
  537. {
  538. return (string) $this->getFullname();
  539. }
  540. }