<?php
function EstimateShipping($shippings, $products, $city)
{
$responseForView = [];
foreach($shippings as $shipping) {
if (!$shipping->allowed()) {
continue;
}
$cost = (new Delivery ($shipping->getCalculator()))->calculate($products, $city);
if ($cost === false) {
continue;
}
$responseForView[] = ['id'=> $shipping->getId(), 'name'=> $shipping->getName(), 'cost' => $cost];
}
return $responseForView;
}