mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
use ArrayIterator;
|
||||
use Chill\BudgetBundle\Entity\Charge;
|
||||
use Chill\BudgetBundle\Entity\Resource;
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
@@ -37,27 +36,23 @@ use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequen
|
||||
use Chill\PersonBundle\Validator\Constraints\Person\Birthdate;
|
||||
use Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Exception;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use UnexpectedValueException;
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Person Class.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_person",
|
||||
* indexes={
|
||||
*
|
||||
* @ORM\Index(
|
||||
* name="person_names",
|
||||
* columns={"firstName", "lastName"}
|
||||
@@ -67,11 +62,15 @@ use function in_array;
|
||||
* columns={"birthdate"}
|
||||
* )
|
||||
* })
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "person": Person::class
|
||||
* })
|
||||
*
|
||||
* @PersonHasCenter
|
||||
*
|
||||
* @HouseholdMembershipSequential(
|
||||
* groups={"household_memberships"}
|
||||
* )
|
||||
@@ -94,8 +93,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* Accept receiving email.
|
||||
*
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*/
|
||||
private ?bool $acceptEmail = false;
|
||||
@@ -103,8 +100,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* Accept short text message (aka SMS).
|
||||
*
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*/
|
||||
private ?bool $acceptSMS = false;
|
||||
@@ -117,6 +112,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
|
||||
* mappedBy="person",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
*
|
||||
* @ORM\OrderBy({"startDate": "DESC"})
|
||||
*/
|
||||
private Collection $accompanyingPeriodParticipations;
|
||||
@@ -139,7 +135,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\Address",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_persons_to_addresses")
|
||||
*
|
||||
* @ORM\OrderBy({"validFrom": "DESC"})
|
||||
*/
|
||||
private Collection $addresses;
|
||||
@@ -159,12 +157,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* The person's birthdate.
|
||||
*
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
*
|
||||
* @Birthdate
|
||||
*/
|
||||
private ?\DateTime $birthdate = null;
|
||||
|
||||
/**
|
||||
* @var Collection<Charge>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=Charge::class,
|
||||
* mappedBy="person"
|
||||
@@ -173,7 +173,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
private Collection $budgetCharges;
|
||||
|
||||
/**
|
||||
* @var Collection<Resource>
|
||||
* @var Collection<resource>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=Resource::class,
|
||||
* mappedBy="person"
|
||||
@@ -183,6 +184,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
|
||||
/**
|
||||
* @var Collection<int, Calendar>
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\CalendarBundle\Entity\Calendar",
|
||||
* mappedBy="persons"
|
||||
@@ -214,7 +216,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* Array where customfield's data are stored.
|
||||
*
|
||||
*
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private ?array $cFData = null;
|
||||
@@ -222,8 +223,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* The marital status of the person.
|
||||
*
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Civility")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private ?\Chill\MainBundle\Entity\Civility $civility = null;
|
||||
@@ -231,7 +232,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* Contact information for contacting the person.
|
||||
*
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private string $contactInfo = '';
|
||||
@@ -239,10 +239,10 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* The person's country of birth.
|
||||
*
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
|
||||
*
|
||||
* sf4 check: option inversedBy="birthsIn" return error mapping !!
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private ?\Chill\MainBundle\Entity\Country $countryOfBirth = null;
|
||||
@@ -254,6 +254,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private ?\Chill\MainBundle\Entity\User $createdBy = null;
|
||||
@@ -280,20 +281,21 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* The person's deathdate.
|
||||
*
|
||||
* @var DateTimeImmutable
|
||||
*
|
||||
* @ORM\Column(type="date_immutable", nullable=true)
|
||||
*
|
||||
* @Assert\Date
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(propertyPath="birthdate")
|
||||
*
|
||||
* @Assert\LessThanOrEqual("today")
|
||||
*/
|
||||
private ?DateTimeImmutable $deathdate = null;
|
||||
private ?\DateTimeImmutable $deathdate = null;
|
||||
|
||||
/**
|
||||
* The person's email.
|
||||
*
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*
|
||||
* @Assert\Email()
|
||||
*/
|
||||
private string $email = '';
|
||||
@@ -302,7 +304,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* The person's first name.
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*
|
||||
* @Assert\NotBlank(message="The firstname cannot be empty")
|
||||
*
|
||||
* @Assert\Length(
|
||||
* max=255,
|
||||
* )
|
||||
@@ -320,8 +324,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* The person's gender.
|
||||
*
|
||||
*
|
||||
* @ORM\Column(type="string", length=9, nullable=true)
|
||||
*
|
||||
* @Assert\NotNull(message="The gender must be set")
|
||||
*/
|
||||
private ?string $gender = null;
|
||||
@@ -337,6 +341,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* Read-only field, computed by the database.
|
||||
*
|
||||
* @var Collection<PersonHouseholdAddress>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=PersonHouseholdAddress::class,
|
||||
* mappedBy="person"
|
||||
@@ -358,7 +363,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* The person's id.
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
@@ -367,7 +374,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* The person's last name.
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*
|
||||
* @Assert\NotBlank(message="The lastname cannot be empty")
|
||||
*
|
||||
* @Assert\Length(
|
||||
* max=255,
|
||||
* )
|
||||
@@ -377,8 +386,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* The marital status of the person.
|
||||
*
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\MaritalStatus")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private ?\Chill\PersonBundle\Entity\MaritalStatus $maritalStatus = null;
|
||||
@@ -394,14 +403,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* The date of the last marital status change of the person.
|
||||
*
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
*
|
||||
* @Assert\Date
|
||||
*/
|
||||
private ?DateTime $maritalStatusDate = null;
|
||||
private ?\DateTime $maritalStatusDate = null;
|
||||
|
||||
/**
|
||||
* A remark over the person.
|
||||
*
|
||||
*
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
private string $memo = ''; // TO-CHANGE in remark
|
||||
@@ -410,6 +419,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* The person's mobile phone number.
|
||||
*
|
||||
* @PhonenumberConstraint(type="mobile")
|
||||
*
|
||||
* @ORM\Column(type="phone_number", nullable=true)
|
||||
*/
|
||||
private ?PhoneNumber $mobilenumber = null;
|
||||
@@ -417,10 +427,10 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* The person's nationality.
|
||||
*
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
|
||||
*
|
||||
* sf4 check: option inversedBy="nationals" return error mapping !!
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private ?\Chill\MainBundle\Entity\Country $nationality = null;
|
||||
@@ -428,8 +438,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* Number of children.
|
||||
*
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private ?int $numberOfChildren = null;
|
||||
@@ -443,6 +451,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* cascade={"persist", "remove", "merge", "detach"},
|
||||
* orphanRemoval=true
|
||||
* )
|
||||
*
|
||||
* @Assert\Valid(
|
||||
* traverse=true,
|
||||
* )
|
||||
@@ -454,6 +463,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* targetEntity=AccompanyingPeriod::class,
|
||||
* mappedBy="personLocation"
|
||||
* )
|
||||
*
|
||||
* @var Collection<AccompanyingPeriod>
|
||||
*/
|
||||
private Collection $periodLocatedOn;
|
||||
@@ -462,6 +472,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* The person's phonenumber.
|
||||
*
|
||||
* @ORM\Column(type="phone_number", nullable=true)
|
||||
*
|
||||
* @PhonenumberConstraint(
|
||||
* type="landline",
|
||||
* )
|
||||
@@ -471,17 +482,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
/**
|
||||
* The person's place of birth.
|
||||
*
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, name="place_of_birth")
|
||||
*/
|
||||
private string $placeOfBirth = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private bool $proxyAccompanyingPeriodOpenState = false; //TO-DELETE ?
|
||||
private bool $proxyAccompanyingPeriodOpenState = false; // TO-DELETE ?
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=PersonResource::class, mappedBy="personOwner")
|
||||
@@ -496,6 +506,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @var Collection<Language>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\Language")
|
||||
*
|
||||
* @ORM\JoinTable(
|
||||
* name="persons_spoken_languages",
|
||||
* joinColumns={@ORM\JoinColumn(name="person_id", referencedColumnName="id")},
|
||||
@@ -539,9 +550,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
$this->centerHistory = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
@@ -616,13 +624,13 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* the person are not collapsing (i.e. have not shared days) or having
|
||||
* a period after an open period.
|
||||
*
|
||||
* @return true | array True if the accompanying periods are not collapsing,
|
||||
* an array with data for displaying the error
|
||||
* @return true|array True if the accompanying periods are not collapsing,
|
||||
* an array with data for displaying the error
|
||||
*/
|
||||
public function checkAccompanyingPeriodsAreNotCollapsing(): array|bool
|
||||
{
|
||||
$periods = $this->getAccompanyingPeriodsOrdered();
|
||||
$periodsNbr = count($periods);
|
||||
$periodsNbr = \count($periods);
|
||||
$i = 0;
|
||||
|
||||
while ($periodsNbr - 1 > $i) {
|
||||
@@ -661,9 +669,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*
|
||||
* To check if the Person and its accompanying period are consistent, use validation.
|
||||
*
|
||||
* @throws Exception if two lines of the accompanying period are open.
|
||||
* @throws \Exception if two lines of the accompanying period are open
|
||||
*/
|
||||
public function close(?AccompanyingPeriod $accompanyingPeriod = null): void
|
||||
public function close(AccompanyingPeriod $accompanyingPeriod = null): void
|
||||
{
|
||||
$this->proxyAccompanyingPeriodOpenState = false;
|
||||
}
|
||||
@@ -701,7 +709,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < count($closeCandidates)) {
|
||||
if (0 < \count($closeCandidates)) {
|
||||
return $closeCandidates[0];
|
||||
}
|
||||
|
||||
@@ -725,7 +733,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* * as participant, only for opened participation;
|
||||
*
|
||||
* @param bool $asParticipantOpen add participation which are still opened
|
||||
* @param bool $asRequestor add accompanying period where the person is requestor
|
||||
* @param bool $asRequestor add accompanying period where the person is requestor
|
||||
*
|
||||
* @return AccompanyingPeriod[]|Collection
|
||||
*/
|
||||
@@ -737,8 +745,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
|
||||
if ($asParticipantOpen) {
|
||||
foreach ($this->getAccompanyingPeriodParticipations()
|
||||
->map(fn (AccompanyingPeriodParticipation $app) => $app->getAccompanyingPeriod())
|
||||
as $period
|
||||
->map(fn (AccompanyingPeriodParticipation $app) => $app->getAccompanyingPeriod()) as $period
|
||||
) {
|
||||
if (!$result->contains($period)) {
|
||||
$result->add($period);
|
||||
@@ -763,7 +770,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
): int {
|
||||
// TODO should be optimized to avoid loading accompanying period ?
|
||||
return $this->getAccompanyingPeriodInvolved($asParticipantOpen, $asRequestor)
|
||||
->filter(fn (AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT)
|
||||
->filter(fn (AccompanyingPeriod $p) => AccompanyingPeriod::STEP_DRAFT !== $p->getStep())
|
||||
->count();
|
||||
}
|
||||
|
||||
@@ -793,7 +800,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
$accompanyingPeriods = [];
|
||||
|
||||
foreach ($this->accompanyingPeriodParticipations as $participation) {
|
||||
/** @var AccompanyingPeriodParticipation $participation */
|
||||
/* @var AccompanyingPeriodParticipation $participation */
|
||||
$accompanyingPeriods[] = $participation->getAccompanyingPeriod();
|
||||
}
|
||||
|
||||
@@ -807,7 +814,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
{
|
||||
$periods = $this->getAccompanyingPeriods();
|
||||
|
||||
//order by date :
|
||||
// order by date :
|
||||
usort($periods, static function ($a, $b) {
|
||||
$dateA = $a->getOpeningDate();
|
||||
$dateB = $b->getOpeningDate();
|
||||
@@ -845,17 +852,17 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*
|
||||
* @deprecated since chill2.0, address is linked to the household. Use @see{Person::getCurrentHouseholdAddress}
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getAddressAt(?DateTimeInterface $at = null): ?Address
|
||||
public function getAddressAt(\DateTimeInterface $at = null): ?Address
|
||||
{
|
||||
$at ??= new DateTime('now');
|
||||
$at ??= new \DateTime('now');
|
||||
|
||||
if ($at instanceof DateTimeImmutable) {
|
||||
$at = DateTime::createFromImmutable($at);
|
||||
if ($at instanceof \DateTimeImmutable) {
|
||||
$at = \DateTime::createFromImmutable($at);
|
||||
}
|
||||
|
||||
/** @var ArrayIterator $addressesIterator */
|
||||
/** @var \ArrayIterator $addressesIterator */
|
||||
$addressesIterator = $this->getAddresses()
|
||||
->filter(static fn (Address $address): bool => $address->getValidFrom() <= $at)
|
||||
->getIterator();
|
||||
@@ -883,12 +890,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*
|
||||
* If the person has a deathdate, calculate the age at the deathdate.
|
||||
*
|
||||
* @param string $at A valid string to create a DateTime.
|
||||
* @param string $at a valid string to create a DateTime
|
||||
*/
|
||||
public function getAge(string $at = 'now'): ?int
|
||||
{
|
||||
if ($this->birthdate instanceof DateTimeInterface) {
|
||||
if ($this->deathdate instanceof DateTimeInterface) {
|
||||
if ($this->birthdate instanceof \DateTimeInterface) {
|
||||
if ($this->deathdate instanceof \DateTimeInterface) {
|
||||
return (int) date_diff($this->birthdate, $this->deathdate)->format('%y');
|
||||
}
|
||||
|
||||
@@ -903,7 +910,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this->altNames;
|
||||
}
|
||||
|
||||
public function getBirthdate(): ?DateTime
|
||||
public function getBirthdate(): ?\DateTime
|
||||
{
|
||||
return $this->birthdate;
|
||||
}
|
||||
@@ -987,7 +994,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this->countryOfBirth;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?DateTimeInterface
|
||||
public function getCreatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
@@ -1015,7 +1022,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
public function getCurrentAccompanyingPeriods(): array
|
||||
{
|
||||
$currentAccompanyingPeriods = [];
|
||||
$currentDate = new DateTime();
|
||||
$currentDate = new \DateTime();
|
||||
|
||||
foreach ($this->accompanyingPeriodParticipations as $participation) {
|
||||
$endDate = $participation->getEndDate();
|
||||
@@ -1028,7 +1035,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $currentAccompanyingPeriods;
|
||||
}
|
||||
|
||||
public function getCurrentHousehold(?DateTimeImmutable $at = null): ?Household
|
||||
public function getCurrentHousehold(\DateTimeImmutable $at = null): ?Household
|
||||
{
|
||||
$participation = $this->getCurrentHouseholdParticipationShareHousehold($at);
|
||||
|
||||
@@ -1043,11 +1050,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* if the given date is 'now', use instead @see{getCurrentPersonAddress}, which is optimized on
|
||||
* database side.
|
||||
*/
|
||||
public function getCurrentHouseholdAddress(?DateTimeImmutable $at = null): ?Address
|
||||
public function getCurrentHouseholdAddress(\DateTimeImmutable $at = null): ?Address
|
||||
{
|
||||
if (
|
||||
null === $at
|
||||
|| $at->format('Ymd') === (new DateTime('today'))->format('Ymd')
|
||||
|| $at->format('Ymd') === (new \DateTime('today'))->format('Ymd')
|
||||
) {
|
||||
return $this->currentPersonAddress instanceof PersonCurrentAddress
|
||||
? $this->currentPersonAddress->getAddress() : null;
|
||||
@@ -1077,11 +1084,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getCurrentHouseholdParticipationShareHousehold(?DateTimeImmutable $at = null): ?HouseholdMember
|
||||
public function getCurrentHouseholdParticipationShareHousehold(\DateTimeImmutable $at = null): ?HouseholdMember
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
$date = $at ?? new DateTimeImmutable('today');
|
||||
$date = $at ?? new \DateTimeImmutable('today');
|
||||
$datef = $date->format('Y-m-d');
|
||||
|
||||
if (
|
||||
@@ -1121,7 +1128,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this->currentPersonAddress->getAddress();
|
||||
}
|
||||
|
||||
public function getDeathdate(): ?DateTimeInterface
|
||||
public function getDeathdate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->deathdate;
|
||||
}
|
||||
@@ -1236,20 +1243,20 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->getFirstName() . ' ' . $this->getLastName();
|
||||
return $this->getFirstName().' '.$this->getLastName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use @see{Person::getCurrentPersonAddress} or @see{Person::getCurrentHouseholdAddress} instead
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return false|mixed|null
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getLastAddress(?DateTime $from = null)
|
||||
public function getLastAddress(\DateTime $from = null)
|
||||
{
|
||||
return $this->getCurrentHouseholdAddress(
|
||||
null !== $from ? DateTimeImmutable::createFromMutable($from) : null
|
||||
null !== $from ? \DateTimeImmutable::createFromMutable($from) : null
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1268,7 +1275,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this->maritalStatusComment;
|
||||
}
|
||||
|
||||
public function getMaritalStatusDate(): ?DateTimeInterface
|
||||
public function getMaritalStatusDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->maritalStatusDate;
|
||||
}
|
||||
@@ -1298,7 +1305,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*/
|
||||
public function getOpenedAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
{
|
||||
if ($this->isOpen() === false) {
|
||||
if (false === $this->isOpen()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1324,7 +1331,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
$criteria = Criteria::create();
|
||||
$criteria
|
||||
->andWhere(Criteria::expr()->eq('endDate', null))
|
||||
->orWhere(Criteria::expr()->gt('endDate', new DateTime('now')));
|
||||
->orWhere(Criteria::expr()->gt('endDate', new \DateTime('now')));
|
||||
|
||||
return $this->getAccompanyingPeriodParticipations()
|
||||
->matching($criteria)
|
||||
@@ -1364,7 +1371,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this->spokenLanguages;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?DateTimeInterface
|
||||
public function getUpdatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
@@ -1374,7 +1381,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function hasCurrentHouseholdAddress(?DateTimeImmutable $at = null): bool
|
||||
public function hasCurrentHouseholdAddress(\DateTimeImmutable $at = null): bool
|
||||
{
|
||||
return null !== $this->getCurrentHouseholdAddress($at);
|
||||
}
|
||||
@@ -1390,7 +1397,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
foreach ($this->addresses as $ad) {
|
||||
$validDate = $ad->getValidFrom()->format('Y-m-d');
|
||||
|
||||
if (in_array($validDate, $validYMDDates, true)) {
|
||||
if (\in_array($validDate, $validYMDDates, true)) {
|
||||
return true;
|
||||
}
|
||||
$validYMDDates[] = $validDate;
|
||||
@@ -1461,7 +1468,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isSharingHousehold(?DateTimeImmutable $at = null): bool
|
||||
public function isSharingHousehold(\DateTimeImmutable $at = null): bool
|
||||
{
|
||||
return null !== $this->getCurrentHousehold($at);
|
||||
}
|
||||
@@ -1490,7 +1497,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
$participation = $this->participationsContainAccompanyingPeriod($accompanyingPeriod);
|
||||
|
||||
if (!null === $participation) {
|
||||
$participation->setEndDate(new DateTime());
|
||||
$participation->setEndDate(new \DateTime());
|
||||
$this->accompanyingPeriodParticipations->removeElement($participation);
|
||||
}
|
||||
}
|
||||
@@ -1555,7 +1562,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $birthdate
|
||||
* @param \DateTime $birthdate
|
||||
*/
|
||||
public function setBirthdate($birthdate): self
|
||||
{
|
||||
@@ -1571,7 +1578,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*/
|
||||
public function setCenter(?Center $center): self
|
||||
{
|
||||
$modification = new DateTimeImmutable('now');
|
||||
$modification = new \DateTimeImmutable('now');
|
||||
|
||||
foreach ($this->centerHistory as $centerHistory) {
|
||||
if (null === $centerHistory->getEndDate()) {
|
||||
@@ -1601,6 +1608,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
$this->centerHistory[] = $newCenterHistory;
|
||||
$newCenterHistory->setPerson($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1611,7 +1619,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCivility(?Civility $civility = null): self
|
||||
public function setCivility(Civility $civility = null): self
|
||||
{
|
||||
$this->civility = $civility;
|
||||
|
||||
@@ -1629,14 +1637,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCountryOfBirth(?Country $countryOfBirth = null): self
|
||||
public function setCountryOfBirth(Country $countryOfBirth = null): self
|
||||
{
|
||||
$this->countryOfBirth = $countryOfBirth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedAt(DateTimeInterface $datetime): self
|
||||
public function setCreatedAt(\DateTimeInterface $datetime): self
|
||||
{
|
||||
$this->createdAt = $datetime;
|
||||
|
||||
@@ -1650,7 +1658,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDeathdate(?DateTimeInterface $deathdate): self
|
||||
public function setDeathdate(?\DateTimeInterface $deathdate): self
|
||||
{
|
||||
$this->deathdate = $deathdate;
|
||||
|
||||
@@ -1699,7 +1707,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMaritalStatus(?MaritalStatus $maritalStatus = null): self
|
||||
public function setMaritalStatus(MaritalStatus $maritalStatus = null): self
|
||||
{
|
||||
$this->maritalStatus = $maritalStatus;
|
||||
|
||||
@@ -1713,7 +1721,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMaritalStatusDate(?DateTimeInterface $maritalStatusDate): self
|
||||
public function setMaritalStatusDate(?\DateTimeInterface $maritalStatusDate): self
|
||||
{
|
||||
$this->maritalStatusDate = $maritalStatusDate;
|
||||
|
||||
@@ -1740,7 +1748,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setNationality(?Country $nationality = null): self
|
||||
public function setNationality(Country $nationality = null): self
|
||||
{
|
||||
$this->nationality = $nationality;
|
||||
|
||||
@@ -1789,7 +1797,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(DateTimeInterface $datetime): self
|
||||
public function setUpdatedAt(\DateTimeInterface $datetime): self
|
||||
{
|
||||
$this->updatedAt = $datetime;
|
||||
|
||||
@@ -1810,7 +1818,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
}
|
||||
|
||||
$criteria = Criteria::create();
|
||||
$now = new DateTimeImmutable('now');
|
||||
$now = new \DateTimeImmutable('now');
|
||||
$criteria->where(Criteria::expr()->lte('startDate', $now))
|
||||
->andWhere(Criteria::expr()->orX(
|
||||
Criteria::expr()->isNull('endDate'),
|
||||
@@ -1822,7 +1830,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return match ($histories->count()) {
|
||||
0 => null,
|
||||
1 => $histories->first(),
|
||||
default => throw new UnexpectedValueException('It should not contains more than one center at a time'),
|
||||
default => throw new \UnexpectedValueException('It should not contains more than one center at a time'),
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user