41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Form\Service\Condition;
|
|
|
|
use App\Form\Model\BookingDto;
|
|
use App\Form\Service\Contract\FieldConditionInterface;
|
|
|
|
/**
|
|
* True for dependent participants when the applicant has a family insurance selected.
|
|
*
|
|
* Family insurance covers the whole family under a single policy on the applicant, so
|
|
* dependents must not be offered their own insurance selection while it's active.
|
|
*/
|
|
class FamilyInsuranceActiveCondition implements FieldConditionInterface
|
|
{
|
|
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
|
|
{
|
|
if (0 === $participantIndex) {
|
|
return false;
|
|
}
|
|
|
|
$applicant = $bookingDto->getParticipant(0);
|
|
|
|
return null !== $applicant
|
|
&& null !== $applicant->insurance
|
|
&& true === $applicant->insurance->familyInsurance;
|
|
}
|
|
|
|
public function getDependentFields(): array
|
|
{
|
|
return ['insurance'];
|
|
}
|
|
|
|
public function getDescription(): string
|
|
{
|
|
return 'Applicant has a family insurance selected';
|
|
}
|
|
}
|