Author: Adam Piotrowski (adam@wellcommerce.org)
 public function calculate(ShippingMethodInterface $shippingMethod, ShippingSubjectInterface $subject) : Collection
 {
     $ranges = $shippingMethod->getCosts();
     $baseCurrency = $subject->getCurrency();
     $targetCurrency = $shippingMethod->getCurrency()->getCode();
     $grossAmount = $this->currencyConverter->convert($subject->getGrossPrice(), $baseCurrency, $targetCurrency);
     return $this->filterRanges($ranges, $grossAmount);
 }
 public function calculate(ShippingMethodInterface $shippingMethod, ShippingSubjectInterface $subject) : Collection
 {
     $ranges = $shippingMethod->getCosts();
     $baseCurrency = $subject->getCurrency();
     $targetCurrency = $shippingMethod->getCurrency()->getCode();
     $grossAmount = $this->currencyConverter->convert($subject->getGrossPrice(), $baseCurrency, $targetCurrency);
     return $ranges->filter(function (ShippingMethodCostInterface $cost) use($grossAmount) {
         return $cost->getRangeFrom() <= $grossAmount && $cost->getRangeTo() >= $grossAmount;
     });
 }
 private function getShippingMethods(ShippingSubjectInterface $subject) : Collection
 {
     $methods = $this->repository->getShippingMethods();
     $country = $subject->getCountry();
     if (strlen($country)) {
         return $methods->filter(function (ShippingMethodInterface $method) use($country) {
             if (count($method->getCountries()) && !in_array($country, $method->getCountries())) {
                 return false;
             }
             return true;
         });
     }
     return $methods;
 }