mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix: Return type of getAge().
Issue highlighted by c68bda5c9b894236860fe1bacca8c9467052eb07.
This commit is contained in:
parent
5432242376
commit
7f02130ff2
@ -839,16 +839,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
*
|
*
|
||||||
* If the person has a deathdate, calculate the age at the deathdate.
|
* 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.
|
||||||
* @return int|null
|
|
||||||
*/
|
*/
|
||||||
public function getAge($at = 'now'): ?int
|
public function getAge(string $at = 'now'): ?int
|
||||||
{
|
{
|
||||||
if ($this->birthdate instanceof \DateTimeInterface) {
|
if ($this->birthdate instanceof \DateTimeInterface) {
|
||||||
if ($this->deathdate instanceof \DateTimeInterface) {
|
if ($this->deathdate instanceof \DateTimeInterface) {
|
||||||
return date_diff($this->birthdate, $this->deathdate)->format("%y");
|
return (int) date_diff($this->birthdate, $this->deathdate)->format('%y');
|
||||||
}
|
}
|
||||||
return date_diff($this->birthdate, date_create($at))->format("%y");
|
|
||||||
|
return (int) date_diff($this->birthdate, date_create($at))->format('%y');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user