feat: adopt new pickups planning payload JSON structure
This commit is contained in:
@@ -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,26 +27,25 @@ 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') : '',
|
||||
];
|
||||
$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;
|
||||
}
|
||||
if (false === isset($result[$code][$key])) {
|
||||
$result[$code][$key] = $pickup;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user