feat: adopt new pickups planning payload JSON structure

This commit is contained in:
Björn Fromme
2026-03-02 11:55:57 +01:00
parent 8e2c688641
commit 590146be9e
2 changed files with 29984 additions and 14 deletions
File diff suppressed because one or more lines are too long
@@ -16,7 +16,7 @@ class PickupPlanningTransformer
/**
* @param array<int, array<string, mixed>> $payload
*
* @return array<string, array<int, array<string, string>>>
* @return array<string, array<int, array{city: string, location: string, datetime: string, busNumber: string}>>
*/
public function transform(array $payload): array
{
@@ -27,28 +27,27 @@ class PickupPlanningTransformer
continue;
}
$travelCodes = $item['Reisecodes'] ?? [];
$code = $item['Reisecode'] ?? '';
if (0 === count($travelCodes)) {
if ('' === $code) {
continue;
}
$dateTime = \DateTimeImmutable::createFromFormat('d.m.Y H:i', $item['Zeit'] ?? '');
foreach ($travelCodes as $code) {
$pickup = [
'city' => $item['Zustieg/Ausstieg Ort'] ?? '',
'location' => $item['Zustieg/Ausstieg Strasse'] ?? '',
'datetime' => false !== $dateTime ? $dateTime->format('Y-m-d H:i') : '',
'busNumber' => $item['BusNummer'] ?? '',
];
$key = sprintf('%s|%s|%s', $pickup['city'], $pickup['location'], $pickup['datetime']);
$key = sprintf('%s|%s|%s|%s', $pickup['city'], $pickup['location'], $pickup['datetime'], $pickup['busNumber']);
if (false === isset($result[$code][$key])) {
$result[$code][$key] = $pickup;
}
}
}
foreach ($result as $code => $pickups) {
$pickups = array_values($pickups);