![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/magento/framework/Pricing/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Pricing; use Magento\Framework\Pricing\Price\Factory as PriceFactory; use Magento\Framework\Pricing\Price\PriceInterface; /** * Composite price model */ class PriceComposite { /** * @var PriceFactory */ protected $priceFactory; /** * @var array */ protected $metadata; /** * @param PriceFactory $priceFactory * @param array $metadata */ public function __construct(PriceFactory $priceFactory, array $metadata = []) { $this->priceFactory = $priceFactory; $this->metadata = $metadata; } /** * @return array */ public function getPriceCodes() { return array_keys($this->metadata); } /** * Returns metadata for prices * * @return array */ public function getMetadata() { return $this->metadata; } /** * @param SaleableInterface $salableItem * @param string $priceCode * @param float $quantity * @return PriceInterface * @throws \InvalidArgumentException */ public function createPriceObject(SaleableInterface $salableItem, $priceCode, $quantity) { if (!isset($this->metadata[$priceCode])) { throw new \InvalidArgumentException($priceCode . ' is not registered in prices list'); } $className = $this->metadata[$priceCode]['class']; return $this->priceFactory->create($salableItem, $className, $quantity); } }