wip: age based filtering of options

This commit is contained in:
Björn Fromme
2026-03-16 11:59:09 +01:00
parent b038d9a41f
commit 7003c0d81b
17 changed files with 845 additions and 23 deletions
+8 -7
View File
@@ -49,12 +49,12 @@ class ServiceAgeEvaluator
return false; // Cannot evaluate without birth date
}
return match($service->ageConstraintType) {
return match ($service->ageConstraintType) {
'absolute_age' => $this->evaluateAbsoluteAge($service, $participant->dateOfBirth),
'birth_year' => $this->evaluateBirthYear($service, $participant->dateOfBirth),
'mixed' => $this->evaluateAbsoluteAge($service, $participant->dateOfBirth)
'mixed' => $this->evaluateAbsoluteAge($service, $participant->dateOfBirth)
&& $this->evaluateBirthYear($service, $participant->dateOfBirth),
default => true // No constraints or unknown type
default => true, // No constraints or unknown type
};
}
@@ -133,13 +133,13 @@ class ServiceAgeEvaluator
*/
public function getConstraintDescription(Service $service): string
{
return match($service->ageConstraintType) {
return match ($service->ageConstraintType) {
'absolute_age' => $this->getAbsoluteAgeDescription($service),
'birth_year' => $this->getBirthYearDescription($service),
'mixed' => sprintf('%s and %s',
'mixed' => sprintf('%s and %s',
$this->getAbsoluteAgeDescription($service),
$this->getBirthYearDescription($service)),
default => 'No age restrictions'
default => 'No age restrictions',
};
}
@@ -180,6 +180,7 @@ class ServiceAgeEvaluator
if ($service->birthYearFrom === $service->birthYearTo) {
return sprintf('Born in %d', $service->birthYearFrom);
}
return sprintf('Born %d-%d', $service->birthYearFrom, $service->birthYearTo);
}
@@ -193,4 +194,4 @@ class ServiceAgeEvaluator
return '';
}
}
}