Files
myep/src/Form/Service/Condition/FirstParticipantCondition.php
T

46 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Form\Service\Condition;
use App\Form\Model\BookingDto;
use App\Form\Service\Contract\FieldConditionInterface;
/**
* Condition that checks if the participant is the first participant (index 0).
*
* This is used to apply field state logic specifically for the first participant
* in the booking, such as requiring address fields or showing DOB-dependent fields.
*
* Note: This checks if the participant is at index 0, NOT if they are the "applicant"
* in the BPN sense (the logged-in user). For agency-initiated bookings, the first
* participant may be different from the applicant/logged-in user.
*/
class FirstParticipantCondition implements FieldConditionInterface
{
/**
* Evaluates if the participant is the first participant.
*
* @param BookingDto $bookingDto The current booking data
* @param int $participantIndex The index of the participant being evaluated
* @param array<string, mixed> $formData Current form data (unused)
*
* @return bool True if the participant is the first participant (index 0)
*/
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
{
return 0 === $participantIndex;
}
public function getDependentFields(): array
{
return [];
}
public function getDescription(): string
{
return 'Checks if the participant is the first participant (index 0)';
}
}