/**
  * @param QuoteProduct $quoteProduct
  * @param string $unitCode
  * @param float $quantity
  * @return QuoteProductOffer|null
  */
 public function match(QuoteProduct $quoteProduct, $unitCode, $quantity)
 {
     $expectedQuantity = (double) $quantity;
     $offers = $quoteProduct->getQuoteProductOffers()->filter(function (QuoteProductOffer $offer) use($unitCode) {
         return $offer->getProductUnitCode() === $unitCode;
     });
     $offers = $this->sortOfferByQuantity($offers->toArray());
     $result = null;
     /** @var QuoteProductOffer[] $offers */
     foreach ($offers as $offer) {
         $quantity = (double) $offer->getQuantity();
         $allowIncrements = $offer->isAllowIncrements();
         if ($quantity > $expectedQuantity) {
             break;
         }
         if ($allowIncrements) {
             $result = $offer;
         } elseif ($quantity === $expectedQuantity) {
             $result = $offer;
             break;
         }
     }
     return $result;
 }