wip: insurance booking phases 1 and 2
This commit is contained in:
@@ -108,21 +108,23 @@ class ParticipantDto
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the participant's current age in complete years.
|
||||
* Calculates the participant's age in complete years.
|
||||
*
|
||||
* Uses the same logic as existing age evaluators in the system
|
||||
* for consistency across age-related calculations.
|
||||
*
|
||||
* @param \DateTimeImmutable|null $referenceDate The date to calculate age at (defaults to current date)
|
||||
*
|
||||
* @return int|null The calculated age in complete years, or null if no birth date
|
||||
*/
|
||||
public function getAge(): ?int
|
||||
public function getAge(?\DateTimeImmutable $referenceDate = null): ?int
|
||||
{
|
||||
if (null === $this->dateOfBirth) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$today = new \DateTimeImmutable();
|
||||
$referenceDate = $referenceDate ?? new \DateTimeImmutable();
|
||||
|
||||
return $this->dateOfBirth->diff($today)->y;
|
||||
return $this->dateOfBirth->diff($referenceDate)->y;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user