vendor/shopware/core/Checkout/Cart/Tax/Struct/TaxRule.php line 12

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Checkout\Cart\Tax\Struct;
  3. use Shopware\Core\Framework\Log\Package;
  4. use Shopware\Core\Framework\Struct\Struct;
  5. use Shopware\Core\Framework\Util\FloatComparator;
  6. use Symfony\Component\Validator\Constraints\NotBlank;
  7. use Symfony\Component\Validator\Constraints\Type;
  8. #[Package('checkout')]
  9. class TaxRule extends Struct
  10. {
  11.     /**
  12.      * @var float
  13.      */
  14.     protected $taxRate;
  15.     /**
  16.      * @var float
  17.      */
  18.     protected $percentage;
  19.     public function __construct(float $taxRatefloat $percentage 100.0)
  20.     {
  21.         $this->taxRate FloatComparator::cast($taxRate);
  22.         $this->percentage FloatComparator::cast($percentage);
  23.     }
  24.     public function getTaxRate(): float
  25.     {
  26.         return FloatComparator::cast($this->taxRate);
  27.     }
  28.     public function getPercentage(): float
  29.     {
  30.         return FloatComparator::cast($this->percentage);
  31.     }
  32.     public static function getConstraints(): array
  33.     {
  34.         return [
  35.             'taxRate' => [new NotBlank(), new Type('numeric')],
  36.             'percentage' => [new Type('numeric')],
  37.         ];
  38.     }
  39.     public function getApiAlias(): string
  40.     {
  41.         return 'cart_tax_rule';
  42.     }
  43. }