feat: adopt new pickups planning payload JSON structure

This commit is contained in:
Björn Fromme
2026-03-16 12:03:00 +01:00
parent f63d52c9d6
commit a7c3064df6
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 * @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 public function transform(array $payload): array
{ {
@@ -27,26 +27,25 @@ class PickupPlanningTransformer
continue; continue;
} }
$travelCodes = $item['Reisecodes'] ?? []; $code = $item['Reisecode'] ?? '';
if (0 === count($travelCodes)) { if ('' === $code) {
continue; continue;
} }
$dateTime = \DateTimeImmutable::createFromFormat('d.m.Y H:i', $item['Zeit'] ?? ''); $dateTime = \DateTimeImmutable::createFromFormat('d.m.Y H:i', $item['Zeit'] ?? '');
foreach ($travelCodes as $code) { $pickup = [
$pickup = [ 'city' => $item['Zustieg/Ausstieg Ort'] ?? '',
'city' => $item['Zustieg/Ausstieg Ort'] ?? '', 'location' => $item['Zustieg/Ausstieg Strasse'] ?? '',
'location' => $item['Zustieg/Ausstieg Strasse'] ?? '', 'datetime' => false !== $dateTime ? $dateTime->format('Y-m-d H:i') : '',
'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])) { if (false === isset($result[$code][$key])) {
$result[$code][$key] = $pickup; $result[$code][$key] = $pickup;
}
} }
} }