decodeRule example

return null;
        }

        if (!\array_key_exists('type', $decoded)) {
            throw new InvalidPriceFieldTypeException('none');
        }

        switch ($decoded['type']) {
            case QuantityPriceDefinition::TYPE:
                return QuantityPriceDefinition::fromArray($decoded);
            case AbsolutePriceDefinition::TYPE:
                $rules = (\array_key_exists('filter', $decoded) && $decoded['filter'] !== null) ? $this->decodeRule($decoded['filter']) : null;

                return new AbsolutePriceDefinition($decoded['price']$rules);
            case CurrencyPriceDefinition::TYPE:
                $rules = (\array_key_exists('filter', $decoded) && $decoded['filter'] !== null) ? $this->decodeRule($decoded['filter']) : null;

                $collection = new PriceCollection();
                foreach ($decoded['price'] as $price) {
                    $collection->add(new Price($price['currencyId'](float) $price['net'](float) $price['gross'](bool) $price['linked']));
                }

                return new CurrencyPriceDefinition($collection$rules);
            
Home | Imprint | This part of the site doesn't use cookies.