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.     public function __construct(
  38.         float $unitPrice,
  39.         float $totalPrice,
  40.         CalculatedTaxCollection $calculatedTaxes,
  41.         TaxRuleCollection $taxRules,
  42.         int $quantity 1,
  43.         ?ReferencePrice $referencePrice null,
  44.         ?ListPrice $listPrice null
  45.     ) {
  46.         $this->unitPrice FloatComparator::cast($unitPrice);
  47.         $this->totalPrice FloatComparator::cast($totalPrice);
  48.         $this->calculatedTaxes $calculatedTaxes;
  49.         $this->taxRules $taxRules;
  50.         $this->quantity $quantity;
  51.         $this->referencePrice $referencePrice;
  52.         $this->listPrice $listPrice;
  53.     }
  54.     public function getTotalPrice(): float
  55.     {
  56.         return FloatComparator::cast($this->totalPrice);
  57.     }
  58.     public function getCalculatedTaxes(): CalculatedTaxCollection
  59.     {
  60.         return $this->calculatedTaxes;
  61.     }
  62.     public function getTaxRules(): TaxRuleCollection
  63.     {
  64.         return $this->taxRules;
  65.     }
  66.     public function getUnitPrice(): float
  67.     {
  68.         return $this->unitPrice;
  69.     }
  70.     public function getQuantity(): int
  71.     {
  72.         return $this->quantity;
  73.     }
  74.     public function getReferencePrice(): ?ReferencePrice
  75.     {
  76.         return $this->referencePrice;
  77.     }
  78.     public function getListPrice(): ?ListPrice
  79.     {
  80.         return $this->listPrice;
  81.     }
  82.     public function getApiAlias(): string
  83.     {
  84.         return 'calculated_price';
  85.     }
  86. }