src/Entity/Person.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Club1895\Club1895Profile;
  4. use App\Entity\Enum\PersonGender;
  5. use App\Entity\Enum\ProfilingType;
  6. use App\Entity\Traits\Identifiable;
  7. use App\Repository\PersonRepository;
  8. use DateInterval;
  9. use DateTime;
  10. use DateTimeImmutable;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use LogicException;
  15. use Symfony\Component\Validator\Constraints\NotBlank;
  16. #[ORM\Entity(repositoryClassPersonRepository::class)]
  17. class Person implements BenefactorPersonInterfaceEmailableInterface
  18. {
  19.     use Identifiable;
  20.     #[ORM\OneToOne(inversedBy'person'targetEntityUser::class, cascade: ['persist''remove'])]
  21.     private $user;
  22.     #[ORM\Column(type'string'length150nullabletrue)]
  23.     private $lastName;
  24.     #[ORM\Column(type'string'length150)]
  25.     #[NotBlank]
  26.     private $firstName;
  27.     #[ORM\Column(type'string'length10nullabletrueenumTypePersonGender::class)]
  28.     private ?PersonGender $gender;
  29.     #[ORM\Column(type'string'length150nullabletrue)]
  30.     private $birthName;
  31.     #[ORM\Column(type'date_immutable'nullabletrue)]
  32.     private $birthDate;
  33.     #[ORM\Column(type'string'length150nullabletrue)]
  34.     private $birthPlace;
  35.     #[ORM\Column(type'string'length100nullabletrue)]
  36.     private $birthCity;
  37.     #[ORM\Column(type'string'length100nullabletrue)]
  38.     private $birthCountry;
  39.     #[ORM\Column(type'string'length100nullabletrue)]
  40.     private $nationality;
  41.     #[ORM\Column(type'string'length150nullabletrue)]
  42.     private $profession;
  43.     #[ORM\Column(type'string'length150nullabletrue)]
  44.     private $school;
  45.     #[ORM\Embedded(PersonMeta::class, 'meta_')]
  46.     private $meta;
  47.     #[ORM\ManyToOne(targetEntityFamily::class, cascade: ['persist'], inversedBy'persons')]
  48.     #[ORM\JoinColumn(onDelete'SET NULL')]
  49.     private $family;
  50.     #[ORM\ManyToOne(targetEntityContactEmail::class, cascade: ['persist'], inversedBy'firstEmailPersons')]
  51.     #[ORM\JoinColumn(onDelete'SET NULL')]
  52.     private $firstEmail;
  53.     #[ORM\ManyToOne(targetEntityContactEmail::class, cascade: ['persist'], inversedBy'secondEmailPersons')]
  54.     #[ORM\JoinColumn(onDelete'SET NULL')]
  55.     private $secondEmail;
  56.     #[ORM\ManyToOne(targetEntityContactPhone::class, cascade: ['persist'], inversedBy'firstPhonePersons')]
  57.     #[ORM\JoinColumn(onDelete'SET NULL')]
  58.     private $firstPhone;
  59.     #[ORM\ManyToOne(targetEntityContactPhone::class, cascade: ['persist'], inversedBy'secondPhonePersons')]
  60.     #[ORM\JoinColumn(onDelete'SET NULL')]
  61.     private $secondPhone;
  62.     #[ORM\OneToMany(mappedBy'owner'targetEntityContactEmail::class, cascade: ['remove'])]
  63.     private $ownedEmails;
  64.     #[ORM\OneToMany(mappedBy'owner'targetEntityContactPhone::class, cascade: ['remove'])]
  65.     private $ownedPhones;
  66.     #[ORM\ManyToMany(targetEntityself::class, inversedBy'tutors')]
  67.     #[ORM\JoinTable(name'tutors')]
  68.     #[ORM\JoinColumn('tutor_id''id')]
  69.     #[ORM\InverseJoinColumn('ward_id''id')]
  70.     private $wards;
  71.     #[ORM\ManyToMany(targetEntityself::class, mappedBy'wards'cascade: ['persist'])]
  72.     private $tutors;
  73.     #[ORM\OneToMany(mappedBy'person'targetEntitySectionPerson::class, cascade: ['persist''remove'])]
  74.     private $sectionPersons;
  75.     #[ORM\OneToMany(mappedBy'person'targetEntityCoach::class, cascade: ['remove'])]
  76.     private $coaches;
  77.     #[ORM\OneToMany(mappedBy'signatory'targetEntityRegistration::class)]
  78.     private $signedRegistrations;
  79.     #[ORM\ManyToMany(targetEntityTag::class, mappedBy'persons')]
  80.     private $tags;
  81.     #[ORM\OneToMany(mappedBy'person'targetEntityRegistration::class, cascade: ['persist''remove'])]
  82.     private $registrations;
  83.     #[ORM\OneToMany(mappedBy'person'targetEntityProfilingPerson::class, cascade: ['persist''remove'])]
  84.     private $profilingPersons;
  85.     #[ORM\Column(type'boolean')]
  86.     private $isNew true;
  87.     #[ORM\Column(type'integer'nullabletrue)]
  88.     private $oldId;
  89.     #[ORM\OneToMany(mappedBy'owner'targetEntityFilePerson::class, cascade: ['remove'])]
  90.     private $files;
  91.     #[ORM\Column(type'boolean')]
  92.     private $isCoach false;
  93.     #[ORM\OneToMany(mappedBy'person'targetEntityDebt::class)]
  94.     private $debts;
  95.     #[ORM\OneToMany(mappedBy'person'targetEntityDonation::class)]
  96.     private Collection $donations;
  97.     #[ORM\Column(options: ['default' => false])]
  98.     private ?bool $benefactor false;
  99.     #[ORM\OneToMany(mappedBy'relatedPerson'targetEntityLegalPerson::class)]
  100.     private Collection $legalPersons;
  101.     #[ORM\OneToOne(mappedBy'person'cascade: ['persist''remove'])]
  102.     private ?Club1895Profile $club1895Profile null;
  103.     #[ORM\Column(nullabletrue)]
  104.     private ?bool $club1895Interested null;
  105.     public function __construct()
  106.     {
  107.         $this->meta = new PersonMeta();
  108.         $this->wards = new ArrayCollection();
  109.         $this->tutors = new ArrayCollection();
  110.         $this->sectionPersons = new ArrayCollection();
  111.         $this->coaches = new ArrayCollection();
  112.         $this->signedRegistrations = new ArrayCollection();
  113.         $this->tags = new ArrayCollection();
  114.         $this->registrations = new ArrayCollection();
  115.         $this->profilingPersons = new ArrayCollection();
  116.         $this->files = new ArrayCollection();
  117.         $this->debts = new ArrayCollection();
  118.         $this->ownedEmails = new ArrayCollection();
  119.         $this->ownedPhones = new ArrayCollection();
  120.         $this->donations = new ArrayCollection();
  121.         $this->legalPersons = new ArrayCollection();
  122.     }
  123.     public function __toString(): string
  124.     {
  125.         return $this->getFullName(true);
  126.     }
  127.     public function getUser(): ?User
  128.     {
  129.         return $this->user;
  130.     }
  131.     public function setUser(?User $user): self
  132.     {
  133.         $this->user $user;
  134.         return $this;
  135.     }
  136.     public function getLastName(): ?string
  137.     {
  138.         return $this->lastName ?? $this->getBirthName();
  139.     }
  140.     public function setLastName(?string $lastName): self
  141.     {
  142.         $this->lastName $lastName;
  143.         return $this;
  144.     }
  145.     public function getFirstName(): ?string
  146.     {
  147.         return $this->firstName;
  148.     }
  149.     public function setFirstName(string $firstName): self
  150.     {
  151.         $this->firstName $firstName;
  152.         return $this;
  153.     }
  154.     public function getGender(): ?PersonGender
  155.     {
  156.         return $this->gender;
  157.     }
  158.     public function setGender(?PersonGender $gender): self
  159.     {
  160.         $this->gender $gender;
  161.         return $this;
  162.     }
  163.     public function getBirthDate(): ?DateTimeImmutable
  164.     {
  165.         return $this->birthDate;
  166.     }
  167.     public function getAge(): ?int
  168.     {
  169.         if (null === $this->getBirthDate()) {
  170.             return 18;
  171.         }
  172.         return $this->getBirthDate()?->diff(new DateTimeImmutable())->y;
  173.     }
  174.     public function setBirthDate(?DateTimeImmutable $birthDate): self
  175.     {
  176.         $this->birthDate $birthDate;
  177.         return $this;
  178.     }
  179.     public function getBirthPlace(): ?string
  180.     {
  181.         return $this->birthPlace;
  182.     }
  183.     public function setBirthPlace(?string $birthPlace): self
  184.     {
  185.         $this->birthPlace $birthPlace;
  186.         return $this;
  187.     }
  188.     public function getNationality(): ?string
  189.     {
  190.         return $this->nationality;
  191.     }
  192.     public function setNationality(?string $nationality): self
  193.     {
  194.         $this->nationality $nationality;
  195.         return $this;
  196.     }
  197.     public function getProfession(): ?string
  198.     {
  199.         return $this->profession;
  200.     }
  201.     public function setProfession(?string $profession): self
  202.     {
  203.         $this->profession $profession;
  204.         return $this;
  205.     }
  206.     public function getSchool(): ?string
  207.     {
  208.         return $this->school;
  209.     }
  210.     public function setSchool(?string $school): self
  211.     {
  212.         $this->school $school;
  213.         return $this;
  214.     }
  215.     public function getFamily(): ?Family
  216.     {
  217.         return $this->family;
  218.     }
  219.     public function setFamily(?Family $family): self
  220.     {
  221.         $this->family $family;
  222.         return $this;
  223.     }
  224.     public function getMeta(): ?PersonMeta
  225.     {
  226.         return $this->meta;
  227.     }
  228.     public function setMeta(PersonMeta $meta): self
  229.     {
  230.         $this->meta $meta;
  231.         return $this;
  232.     }
  233.     public function getFirstEmail(): ?ContactEmail
  234.     {
  235.         return $this->firstEmail;
  236.     }
  237.     public function setFirstEmail(?ContactEmail $firstEmail): self
  238.     {
  239.         $this->firstEmail $firstEmail;
  240.         if ($firstEmail && null === $firstEmail->getOwner()) {
  241.             $firstEmail->setOwner($this);
  242.         }
  243.         return $this;
  244.     }
  245.     public function getSecondEmail(): ?ContactEmail
  246.     {
  247.         return $this->secondEmail;
  248.     }
  249.     public function setSecondEmail(?ContactEmail $secondEmail): self
  250.     {
  251.         $this->secondEmail $secondEmail;
  252.         if ($secondEmail && null === $secondEmail->getOwner()) {
  253.             $secondEmail->setOwner($this);
  254.         }
  255.         return $this;
  256.     }
  257.     public function getEmail(bool $ownedOnly false): ?ContactEmail
  258.     {
  259.         if ($ownedOnly) {
  260.             if ($this->getFirstEmail()?->getOwner() === $this) {
  261.                 return $this->getFirstEmail();
  262.             } elseif ($this->getSecondEmail()?->getOwner() === $this) {
  263.                 return $this->getSecondEmail();
  264.             } else {
  265.                 return null;
  266.             }
  267.         }
  268.         return $this->getFirstEmail() ?? $this->getSecondEmail();
  269.     }
  270.     /**
  271.      * @return Collection<int, ContactEmail>
  272.      */
  273.     public function getEmails(): Collection
  274.     {
  275.         $emails = new ArrayCollection();
  276.         if ($this->getFirstEmail()) {
  277.             $emails->add($this->getFirstEmail());
  278.         }
  279.         if ($this->getSecondEmail()) {
  280.             $emails->add($this->getSecondEmail());
  281.         }
  282.         return $emails;
  283.     }
  284.     public function getValidEmail(): ?string
  285.     {
  286.         $contactEmail $this->getEmail();
  287.         if ($contactEmail) {
  288.             return $contactEmail->getEmail();
  289.         }
  290.         foreach ($this->getTutors() as $tutor) {
  291.             if ($contactEmail $tutor->getEmail()) {
  292.                 return $contactEmail->getEmail();
  293.             }
  294.         }
  295.         return $this->getFamily()?->getResponsiblePerson()?->getEmail()?->getEmail();
  296.     }
  297.     public function getSimpleEmail(): ?string
  298.     {
  299.         return $this->getEmail()?->getEmail();
  300.     }
  301.     public function getFirstPhone(): ?ContactPhone
  302.     {
  303.         return $this->firstPhone;
  304.     }
  305.     public function setFirstPhone(?ContactPhone $firstPhone): self
  306.     {
  307.         $this->firstPhone $firstPhone;
  308.         if ($firstPhone && null === $firstPhone->getOwner()) {
  309.             $firstPhone->setOwner($this);
  310.         }
  311.         return $this;
  312.     }
  313.     public function getSecondPhone(): ?ContactPhone
  314.     {
  315.         return $this->secondPhone;
  316.     }
  317.     public function setSecondPhone(?ContactPhone $secondPhone): self
  318.     {
  319.         $this->secondPhone $secondPhone;
  320.         if ($secondPhone && null === $secondPhone->getOwner()) {
  321.             $secondPhone->setOwner($this);
  322.         }
  323.         return $this;
  324.     }
  325.     /**
  326.      * @return Collection<int, ContactPhone>
  327.      */
  328.     public function getPhones(): Collection
  329.     {
  330.         $phones = new ArrayCollection();
  331.         if ($this->getFirstPhone()) {
  332.             $phones->add($this->getFirstPhone());
  333.         }
  334.         if ($this->getSecondPhone()) {
  335.             $phones->add($this->getSecondPhone());
  336.         }
  337.         return $phones;
  338.     }
  339.     /**
  340.      * @return Collection<int, ContactInterface>
  341.      */
  342.     public function getContacts(): Collection
  343.     {
  344.         $contacts = new ArrayCollection();
  345.         foreach ($this->getEmails() as $email) {
  346.             $contacts->add($email);
  347.         }
  348.         foreach ($this->getPhones() as $phone) {
  349.             $contacts->add($phone);
  350.         }
  351.         return $contacts;
  352.     }
  353.     /**
  354.      * @return Collection<int, self>
  355.      */
  356.     public function getWards(): Collection
  357.     {
  358.         return $this->wards;
  359.     }
  360.     public function addWard(self $ward): self
  361.     {
  362.         if (!$this->wards->contains($ward)) {
  363.             $this->wards[] = $ward;
  364.         }
  365.         return $this;
  366.     }
  367.     public function removeWard(self $ward): self
  368.     {
  369.         $this->wards->removeElement($ward);
  370.         return $this;
  371.     }
  372.     /**
  373.      * @param array|Person[] $wards
  374.      * @return Person
  375.      */
  376.     public function setWards(array $wards): Person
  377.     {
  378.         $collection = new ArrayCollection();
  379.         foreach ($wards as $ward) {
  380.             if (!$collection->contains($ward)) {
  381.                 $collection->add($ward);
  382.             }
  383.         }
  384.         $this->wards $collection;
  385.         return $this;
  386.     }
  387.     /**
  388.      * @return Collection<int, self>
  389.      */
  390.     public function getTutors(): Collection
  391.     {
  392.         return $this->tutors;
  393.     }
  394.     public function addTutor(self $tutor): self
  395.     {
  396.         if (!$this->tutors->contains($tutor)) {
  397.             $this->tutors[] = $tutor;
  398.             $tutor->addWard($this);
  399.         }
  400.         return $this;
  401.     }
  402.     public function removeTutor(self $tutor): self
  403.     {
  404.         if ($this->tutors->removeElement($tutor)) {
  405.             $tutor->removeWard($this);
  406.         }
  407.         return $this;
  408.     }
  409.     /**
  410.      * @param array|Person[] $tutors
  411.      * @return Person
  412.      */
  413.     public function setTutors(array $tutors): Person
  414.     {
  415.         $collection = new ArrayCollection();
  416.         foreach ($tutors as $tutor) {
  417.             if (!$collection->contains($tutor)) {
  418.                 $collection->add($tutor);
  419.             }
  420.         }
  421.         $this->tutors $collection;
  422.         return $this;
  423.     }
  424.     public function getBirthCity(): ?string
  425.     {
  426.         return $this->birthCity;
  427.     }
  428.     public function setBirthCity(?string $birthCity): self
  429.     {
  430.         $this->birthCity $birthCity;
  431.         return $this;
  432.     }
  433.     public function getBirthCountry(): ?string
  434.     {
  435.         return $this->birthCountry;
  436.     }
  437.     public function setBirthCountry(?string $birthCountry): self
  438.     {
  439.         $this->birthCountry $birthCountry;
  440.         return $this;
  441.     }
  442.     /**
  443.      * @param Section|null $section
  444.      * @return Collection<int, SectionPerson>
  445.      */
  446.     public function getSectionPersons(?Section $section null): Collection
  447.     {
  448.         if ($section) {
  449.             return $this->sectionPersons->filter(
  450.                 fn(SectionPerson $sectionPerson) => $sectionPerson->getSection() === $section
  451.             );
  452.         }
  453.         return $this->sectionPersons;
  454.     }
  455.     public function addSectionPerson(SectionPerson $sectionPerson): self
  456.     {
  457.         if (!$this->sectionPersons->contains($sectionPerson)) {
  458.             $this->sectionPersons[] = $sectionPerson;
  459.             $sectionPerson->setPerson($this);
  460.         }
  461.         return $this;
  462.     }
  463.     public function removeSectionPerson(SectionPerson $sectionPerson): self
  464.     {
  465.         if ($this->sectionPersons->removeElement($sectionPerson)) {
  466.             // set the owning side to null (unless already changed)
  467.             if ($sectionPerson->getPerson() === $this) {
  468.                 $sectionPerson->setPerson(null);
  469.             }
  470.         }
  471.         return $this;
  472.     }
  473.     /**
  474.      * @return Collection<int, Coach>
  475.      */
  476.     public function getCoaches(): Collection
  477.     {
  478.         return $this->coaches;
  479.     }
  480.     public function addCoach(Coach $coach): self
  481.     {
  482.         if (!$this->coaches->contains($coach)) {
  483.             $this->coaches[] = $coach;
  484.             $coach->setPerson($this);
  485.         }
  486.         return $this;
  487.     }
  488.     public function removeCoach(Coach $coach): self
  489.     {
  490.         if ($this->coaches->removeElement($coach)) {
  491.             // set the owning side to null (unless already changed)
  492.             if ($coach->getPerson() === $this) {
  493.                 $coach->setPerson(null);
  494.             }
  495.         }
  496.         return $this;
  497.     }
  498.     /**
  499.      * @return Collection<int, Registration>
  500.      */
  501.     public function getSignedRegistrations(): Collection
  502.     {
  503.         return $this->signedRegistrations;
  504.     }
  505.     public function addSignedRegistration(Registration $signedRegistration): self
  506.     {
  507.         if (!$this->signedRegistrations->contains($signedRegistration)) {
  508.             $this->signedRegistrations[] = $signedRegistration;
  509.             $signedRegistration->setSignatory($this);
  510.         }
  511.         return $this;
  512.     }
  513.     public function removeSignedRegistration(Registration $signedRegistration): self
  514.     {
  515.         if ($this->signedRegistrations->removeElement($signedRegistration)) {
  516.             // set the owning side to null (unless already changed)
  517.             if ($signedRegistration->getSignatory() === $this) {
  518.                 $signedRegistration->setSignatory(null);
  519.             }
  520.         }
  521.         return $this;
  522.     }
  523.     /**
  524.      * @return Collection<int, Tag>
  525.      */
  526.     public function getTags(): Collection
  527.     {
  528.         return $this->tags;
  529.     }
  530.     public function addTag(Tag $tag): self
  531.     {
  532.         if (!$this->tags->contains($tag)) {
  533.             $this->tags[] = $tag;
  534.             $tag->addPerson($this);
  535.         }
  536.         return $this;
  537.     }
  538.     public function removeTag(Tag $tag): self
  539.     {
  540.         if ($this->tags->removeElement($tag)) {
  541.             $tag->removePerson($this);
  542.         }
  543.         return $this;
  544.     }
  545.     /**
  546.      * @param array $tags
  547.      * @return Person
  548.      */
  549.     public function setTags(array $tags): Person
  550.     {
  551.         $collection = new ArrayCollection();
  552.         foreach ($tags as $tag) {
  553.             $collection->add($tag);
  554.         }
  555.         $this->tags $collection;
  556.         return $this;
  557.     }
  558.     /**
  559.      * @param Section|null $section
  560.      * @return Collection<int, Registration>
  561.      */
  562.     public function getRegistrations(?Section $section null): Collection
  563.     {
  564.         if (null === $section) {
  565.             return $this->registrations;
  566.         }
  567.         return $this->registrations->filter(fn(Registration $r) => $r->getSection() === $section);
  568.     }
  569.     public function getPreviousSeasonRegistrations()
  570.     {
  571.     }
  572.     public function addRegistration(Registration $registration): self
  573.     {
  574.         if (!$this->registrations->contains($registration)) {
  575.             $this->registrations[] = $registration;
  576.             $registration->setPerson($this);
  577.         }
  578.         return $this;
  579.     }
  580.     public function removeRegistration(Registration $registration): self
  581.     {
  582.         if ($this->registrations->removeElement($registration)) {
  583.             // set the owning side to null (unless already changed)
  584.             if ($registration->getPerson() === $this) {
  585.                 $registration->setPerson(null);
  586.             }
  587.         }
  588.         return $this;
  589.     }
  590.     /**
  591.      * @param Section|null $section
  592.      * @return Collection<int, Registration>
  593.      */
  594.     public function getActiveRegistrations(?Section $section null): Collection
  595.     {
  596.         return $this->getRegistrations($section)->filter(fn(Registration $r) => $r->getSeason()->getIsActive());
  597.     }
  598.     /**
  599.      * @return Collection<int, ProfilingPerson>
  600.      */
  601.     public function getProfilingPersons(): Collection
  602.     {
  603.         return $this->profilingPersons;
  604.     }
  605.     public function getSectionLevelPerson(Section $sectionbool $activeSeason true): ?ProfilingPerson
  606.     {
  607.         foreach ($this->getProfilingPersons() as $profilingPerson) {
  608.             if ($profilingPerson->getType() === ProfilingType::Level
  609.                 && $profilingPerson->getSeason()?->getSection() === $section) {
  610.                 if ($activeSeason && $profilingPerson->getSeason()?->getIsActive()) {
  611.                     return $profilingPerson;
  612.                 }
  613.                 if (!$activeSeason && $profilingPerson->getSeason()?->getNextSeason()?->getIsActive()) {
  614.                     return $profilingPerson;
  615.                 }
  616.             }
  617.         }
  618.         return null;
  619.     }
  620.     public function getSectionProfilingPerson(Section $section): ?ProfilingPerson
  621.     {
  622.         foreach ($this->getProfilingPersons() as $profilingPerson) {
  623.             if ($profilingPerson->getType() === ProfilingType::Profiling
  624.                 && $profilingPerson->getSeason()?->getIsActive()
  625.                 && $profilingPerson->getSeason()?->getSection() === $section) {
  626.                 return $profilingPerson;
  627.             }
  628.         }
  629.         return null;
  630.     }
  631.     public function addProfilingPerson(ProfilingPerson $profilingPerson): self
  632.     {
  633.         if (!$this->profilingPersons->contains($profilingPerson)) {
  634.             $this->profilingPersons[] = $profilingPerson;
  635.             $profilingPerson->setPerson($this);
  636.         }
  637.         return $this;
  638.     }
  639.     public function removeProfilingPerson(ProfilingPerson $profilingPerson): self
  640.     {
  641.         if ($this->profilingPersons->removeElement($profilingPerson)) {
  642.             // set the owning side to null (unless already changed)
  643.             if ($profilingPerson->getPerson() === $this) {
  644.                 $profilingPerson->setPerson(null);
  645.             }
  646.         }
  647.         return $this;
  648.     }
  649.     public function getBirthName(): ?string
  650.     {
  651.         return $this->birthName;
  652.     }
  653.     public function setBirthName(?string $birthName): self
  654.     {
  655.         $this->birthName $birthName;
  656.         return $this;
  657.     }
  658.     public function getFullName(bool $capitalize false): string
  659.     {
  660.         return sprintf(
  661.             '%s %s',
  662.             $this->getFirstName(),
  663.             $capitalize mb_strtoupper($this->getLastName()) : $this->getLastName()
  664.         );
  665.     }
  666.     /**
  667.      * @return bool
  668.      * @throws LogicException
  669.      */
  670.     public function isMinor(): bool
  671.     {
  672.         if (null === $this->getBirthDate()) {
  673.             return false;
  674.         }
  675.         $date = (new DateTime())->sub(new DateInterval('P18Y'));
  676.         return $this->getBirthDate() > $date;
  677.     }
  678.     public function isIsNew(): ?bool
  679.     {
  680.         return $this->isNew;
  681.     }
  682.     public function setIsNew(bool $isNew): self
  683.     {
  684.         $this->isNew $isNew;
  685.         return $this;
  686.     }
  687.     public function getOldId(): ?int
  688.     {
  689.         return $this->oldId;
  690.     }
  691.     public function setOldId(?int $oldId): self
  692.     {
  693.         $this->oldId $oldId;
  694.         return $this;
  695.     }
  696.     /**
  697.      * @return Collection<int, FilePerson>
  698.      */
  699.     public function getFiles(): Collection
  700.     {
  701.         return $this->files;
  702.     }
  703.     public function addFile(FilePerson $file): self
  704.     {
  705.         if (!$this->files->contains($file)) {
  706.             $this->files[] = $file;
  707.             $file->setOwner($this);
  708.         }
  709.         return $this;
  710.     }
  711.     public function removeFile(FilePerson $file): self
  712.     {
  713.         if ($this->files->removeElement($file)) {
  714.             // set the owning side to null (unless already changed)
  715.             if ($file->getOwner() === $this) {
  716.                 $file->setOwner(null);
  717.             }
  718.         }
  719.         return $this;
  720.     }
  721.     public function isIsCoach(): ?bool
  722.     {
  723.         return $this->isCoach;
  724.     }
  725.     public function setIsCoach(bool $isCoach): self
  726.     {
  727.         $this->isCoach $isCoach;
  728.         return $this;
  729.     }
  730.     /**
  731.      * @param Section|null $section
  732.      * @return Collection<int, Debt>
  733.      */
  734.     public function getDebts(?Section $section null): Collection
  735.     {
  736.         if ($section) {
  737.             return $this->debts->filter(fn(Debt $debt) => $debt->getSection()?->getId() === $section->getId());
  738.         }
  739.         return $this->debts;
  740.     }
  741.     public function addDebt(Debt $debt): self
  742.     {
  743.         if (!$this->debts->contains($debt)) {
  744.             $this->debts[] = $debt;
  745.             $debt->setPerson($this);
  746.         }
  747.         return $this;
  748.     }
  749.     public function removeDebt(Debt $debt): self
  750.     {
  751.         if ($this->debts->removeElement($debt)) {
  752.             // set the owning side to null (unless already changed)
  753.             if ($debt->getPerson() === $this) {
  754.                 $debt->setPerson(null);
  755.             }
  756.         }
  757.         return $this;
  758.     }
  759.     /**
  760.      * @return Collection<int, ContactEmail>
  761.      */
  762.     public function getOwnedEmails(): Collection
  763.     {
  764.         return $this->ownedEmails;
  765.     }
  766.     public function addOwnedEmail(ContactEmail $ownedEmail): self
  767.     {
  768.         if (!$this->ownedEmails->contains($ownedEmail)) {
  769.             $this->ownedEmails[] = $ownedEmail;
  770.             $ownedEmail->setOwner($this);
  771.         }
  772.         return $this;
  773.     }
  774.     public function removeOwnedEmail(ContactEmail $ownedEmail): self
  775.     {
  776.         if ($this->ownedEmails->removeElement($ownedEmail)) {
  777.             // set the owning side to null (unless already changed)
  778.             if ($ownedEmail->getOwner() === $this) {
  779.                 $ownedEmail->setOwner(null);
  780.             }
  781.         }
  782.         return $this;
  783.     }
  784.     /**
  785.      * @return Collection<int, ContactPhone>
  786.      */
  787.     public function getOwnedPhones(): Collection
  788.     {
  789.         return $this->ownedPhones;
  790.     }
  791.     public function addOwnedPhone(ContactPhone $ownedPhone): self
  792.     {
  793.         if (!$this->ownedPhones->contains($ownedPhone)) {
  794.             $this->ownedPhones[] = $ownedPhone;
  795.             $ownedPhone->setOwner($this);
  796.         }
  797.         return $this;
  798.     }
  799.     public function removeOwnedPhone(ContactPhone $ownedPhone): self
  800.     {
  801.         if ($this->ownedPhones->removeElement($ownedPhone)) {
  802.             // set the owning side to null (unless already changed)
  803.             if ($ownedPhone->getOwner() === $this) {
  804.                 $ownedPhone->setOwner(null);
  805.             }
  806.         }
  807.         return $this;
  808.     }
  809.     /**
  810.      * @return Collection<int, Donation>
  811.      */
  812.     public function getDonations(): Collection
  813.     {
  814.         return $this->donations;
  815.     }
  816.     public function addDonation(Donation $donation): self
  817.     {
  818.         if (!$this->donations->contains($donation)) {
  819.             $this->donations->add($donation);
  820.             $donation->setPerson($this);
  821.         }
  822.         return $this;
  823.     }
  824.     public function removeDonation(Donation $donation): self
  825.     {
  826.         if ($this->donations->removeElement($donation)) {
  827.             // set the owning side to null (unless already changed)
  828.             if ($donation->getPerson() === $this) {
  829.                 $donation->setPerson(null);
  830.             }
  831.         }
  832.         return $this;
  833.     }
  834.     public function isBenefactor(): ?bool
  835.     {
  836.         return $this->benefactor;
  837.     }
  838.     public function setBenefactor(bool $benefactor): self
  839.     {
  840.         $this->benefactor $benefactor;
  841.         return $this;
  842.     }
  843.     /**
  844.      * @return Collection<int, LegalPerson>
  845.      */
  846.     public function getLegalPersons(): Collection
  847.     {
  848.         return $this->legalPersons;
  849.     }
  850.     public function addLegalPerson(LegalPerson $legalPerson): self
  851.     {
  852.         if (!$this->legalPersons->contains($legalPerson)) {
  853.             $this->legalPersons->add($legalPerson);
  854.             $legalPerson->setRelatedPerson($this);
  855.         }
  856.         return $this;
  857.     }
  858.     public function removeLegalPerson(LegalPerson $legalPerson): self
  859.     {
  860.         if ($this->legalPersons->removeElement($legalPerson)) {
  861.             // set the owning side to null (unless already changed)
  862.             if ($legalPerson->getRelatedPerson() === $this) {
  863.                 $legalPerson->setRelatedPerson(null);
  864.             }
  865.         }
  866.         return $this;
  867.     }
  868.     public function getClub1895Profile(): ?Club1895Profile
  869.     {
  870.         return $this->club1895Profile;
  871.     }
  872.     public function setClub1895Profile(Club1895Profile $club1895Profile): self
  873.     {
  874.         // set the owning side of the relation if necessary
  875.         if ($club1895Profile->getPerson() !== $this) {
  876.             $club1895Profile->setPerson($this);
  877.         }
  878.         $this->club1895Profile $club1895Profile;
  879.         return $this;
  880.     }
  881.     public function isClub1895Interested(): ?bool
  882.     {
  883.         return $this->club1895Interested;
  884.     }
  885.     public function setClub1895Interested(?bool $club1895Interested): self
  886.     {
  887.         $this->club1895Interested $club1895Interested;
  888.         return $this;
  889.     }
  890. }