getFilterSorterKey example

public function __construct(private readonly FilterServiceRegistry $registry)
    {
    }

    public function getDecorated(): PackageFilter
    {
        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);

        
static::assertInstanceOf(QuantityPriceDefinition::class$this->discount->getPriceDefinition());
    }

    /** * This test verifies that the property is correctly * assigned as well as returned in the getter function. * * @group promotions */
    public function testSorterApplierKey(): void
    {
        static::assertEquals('PRICE_ASC', $this->discount->getFilterSorterKey());
    }

    /** * This test verifies that the property is correctly * assigned as well as returned in the getter function. * * @group promotions */
    public function testFilterApplierKey(): void
    {
        static::assertEquals('ALL', $this->discount->getFilterApplierKey());
    }
Home | Imprint | This part of the site doesn't use cookies.