throw new DecorationPatternException(self::
class);
} public function filterPackages(DiscountLineItem
$discount, DiscountPackageCollection
$packages, int
$originalPackageCount): DiscountPackageCollection
{ $sorterKey =
$discount->
getFilterSorterKey();
$applierKey =
$discount->
getFilterApplierKey();
$countKey =
$discount->
getFilterUsageKey();
$filteredPackages =
[];
if (!
$this->
hasFilterSettings($sorterKey,
$applierKey,
$countKey)) { return new DiscountPackageCollection($packages);
} // now sort each found package depending on our configured sorter
$sortedPackages =
$this->registry->
getSorter($sorterKey)->
sort($packages);
// calculate an additional maximal count
// of items that need to be discounted
$maxUsage =
new MaxUsage();
$maxItems =
$maxUsage->
getMaxItemCount($applierKey,
$countKey,
$originalPackageCount);