/** * Sets tax information * * @throws InvalidArgumentException If $amount is negative * * @param float $amount The positive tax amount as a percentage * @param string $type The type of tax the $amount represents. One of: * - inclusive Prices include tax * - exclusive Prices do not include tax */ public function __construct($amount, $type) { // Amount must be non-negative if (!is_numeric($amount) || $amount < 0) { throw new InvalidArgumentException(sprintf('TaxPrice must be instantiated with a positive amount.')); } parent::__construct($amount, $type); }
/** * Sets discount information * * @throws InvalidArgumentException If $amount is negative * * @param float $amount The positive amount to discount * @param string $type The type of discount the $amount represents. One of: * - percent The $amount represents a percentage discount (NOT already divided by 100) * - amount The $amount represents an amount discount */ public function __construct($amount, $type) { // Amount must be non-negative if (!is_numeric($amount) || $amount < 0) { throw new InvalidArgumentException(sprintf('DiscountPrice must be instantiated with a positive amount.')); } parent::__construct($amount, $type); // Keep a running total of the remaining discount for amounts $this->discount_remaining = 0; if ('percent' !== $this->type) { $this->discount_remaining = $amount; } }