// detect the latest delivery date
$earliest =
$max->
getEarliest() >
$date->
getEarliest() ?
$max->
getEarliest() :
$date->
getEarliest();
$latest =
$max->
getLatest() >
$date->
getLatest() ?
$max->
getLatest() :
$date->
getLatest();
// if earliest and latest is same date, add one day buffer
if ($earliest->
format('Y-m-d'
) ===
$latest->
format('Y-m-d'
)) { $latest =
$latest->
add(new \
DateInterval('P1D'
));
} $max =
new DeliveryDate($earliest,
$latest);
} return $max;
} private function buildPositions( LineItemCollection
$items,
DeliveryPositionCollection
$positions,
?DeliveryTime
$default ): void
{ foreach ($items as $item) {