feat: refactoring and cleanup

This commit is contained in:
Björn Fromme committed 2025-12-06 15:02:13 +01:00
1 parent f4691ec67e
commit 696800aafd
41 files changed
+2591 -2233

No files matched your search

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace App\Form\Service;
use App\BusProNet\Model\Service;
use App\BusProNet\Utility\DirectionMapper;
use App\Form\Model\BookingDto;
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
@@ -57,43 +56,7 @@ class ParticipantTransportationOutboundFieldHandler extends AbstractParticipantF
true // filter available
);
// Validate and convert selection to Service object
$validSelection = null;
if (null !== $selectedTransportation) {
$validSelection = $this->findValidTransportationService(
$selectedTransportation,
$availableServices
);
}
// Update participant with validated selection
$participant->transportationOutbound = $validSelection;
}
/**
* Finds a valid transportation service from available services.
*
* @param mixed $selectedServiceId The submitted service ID
* @param array<int, Service> $availableServices Array of available transportation services
*
* @return Service|null The valid service object, or null if invalid
*/
private function findValidTransportationService(
mixed $selectedServiceId,
array $availableServices,
): ?Service {
if (null === $selectedServiceId || false === is_string($selectedServiceId) && false === is_int($selectedServiceId)) {
return null;
}
$serviceId = (int) $selectedServiceId;
foreach ($availableServices as $service) {
if ($service->id === $serviceId) {
return $service;
}
}
return null;
// Validate and update participant with selection
$participant->transportationOutbound = $this->findItemById($selectedTransportation, $availableServices);
}
}