vendor/shopware/core/Checkout/Cart/Price/Struct/CalculatedPrice.php line 10

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Checkout\Cart\Price\Struct;
  3. use Shopware\Core\Checkout\Cart\Tax\Struct\CalculatedTaxCollection;
  4. use Shopware\Core\Checkout\Cart\Tax\Struct\TaxRuleCollection;
  5. use Shopware\Core\Framework\Struct\Struct;
  6. use Shopware\Core\Framework\Util\FloatComparator;
  7. class CalculatedPrice extends Struct
  8. {
  9.     /**
  10.      * @var float
  11.      */
  12.     protected $unitPrice;
  13.     /**
  14.      * @var int
  15.      */
  16.     protected $quantity;
  17.     /**
  18.      * @var float
  19.      */
  20.     protected $totalPrice;
  21.     /**
  22.      * @var CalculatedTaxCollection
  23.      */
  24.     protected $calculatedTaxes;
  25.     /**
  26.      * @var TaxRuleCollection
  27.      */
  28.     protected $taxRules;
  29.     /**
  30.      * @var ReferencePrice
  31.      */
  32.     protected $referencePrice;
  33.     /**
  34.      * @var ListPrice|null
  35.      */
  36.     protected $listPrice;
  37.     /**
  38.      * @var RegulationPrice|null
  39.      */
  40.     protected $regulationPrice;
  41.     public function __construct(
  42.         float $unitPrice,
  43.         float $totalPrice,
  44.         CalculatedTaxCollection $calculatedTaxes,
  45.         TaxRuleCollection $taxRules,
  46.         int $quantity 1,
  47.         ?ReferencePrice $referencePrice null,
  48.         ?ListPrice $listPrice null,
  49.         ?RegulationPrice $regulationPrice null
  50.     ) {
  51.         $this->unitPrice FloatComparator::cast($unitPrice);
  52.         $this->totalPrice FloatComparator::cast($totalPrice);
  53.         $this->calculatedTaxes $calculatedTaxes;
  54.         $this->taxRules $taxRules;
  55.         $this->quantity $quantity;
  56.         $this->referencePrice $referencePrice;
  57.         $this->listPrice $listPrice;
  58.         $this->regulationPrice $regulationPrice;
  59.     }
  60.     public function getTotalPrice(): float
  61.     {
  62.         return FloatComparator::cast($this->totalPrice);
  63.     }
  64.     public function getCalculatedTaxes(): CalculatedTaxCollection
  65.     {
  66.         return $this->calculatedTaxes;
  67.     }
  68.     public function getTaxRules(): TaxRuleCollection
  69.     {
  70.         return $this->taxRules;
  71.     }
  72.     public function getUnitPrice(): float
  73.     {
  74.         return $this->unitPrice;
  75.     }
  76.     public function getQuantity(): int
  77.     {
  78.         return $this->quantity;
  79.     }
  80.     public function getReferencePrice(): ?ReferencePrice
  81.     {
  82.         return $this->referencePrice;
  83.     }
  84.     public function getListPrice(): ?ListPrice
  85.     {
  86.         return $this->listPrice;
  87.     }
  88.     public function getRegulationPrice(): ?RegulationPrice
  89.     {
  90.         return $this->regulationPrice;
  91.     }
  92.     public function getApiAlias(): string
  93.     {
  94.         return 'calculated_price';
  95.     }
  96. }