feat: adopt new pickups planning payload JSON structure
This commit is contained in:
+29972
-1
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,28 +27,27 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($result as $code => $pickups) {
|
foreach ($result as $code => $pickups) {
|
||||||
$pickups = array_values($pickups);
|
$pickups = array_values($pickups);
|
||||||
|
|||||||
Reference in New Issue
Block a user