handleError(new Exception(sprintf("Coupon type '%s' not supported", $type))); } $this->availableTaxClasses = $context->getAvailableTaxClassSlugs(); $this->type = $type; $this->name = (string)$name; $this->value = floatval($value); $this->ruleId = $ruleId; $this->taxClass = in_array($taxClass, $this->availableTaxClasses) ? $taxClass : ""; } public function withContext(Context $context) { $this->availableTaxClasses = $context->getAvailableTaxClassSlugs(); } /** * @return string */ public function getType() { return $this->type; } /** * @param string $type * * @return bool */ public function isType($type) { return $this->type === $type; } /** * @param string $name */ public function setName($name) { $this->name = (string)$name; } /** * @return string */ public function getName() { return $this->name; } /** * @param float $value */ public function setValue($value) { $this->value = floatval($value); } /** * @return float */ public function getValue() { return $this->value; } /** * @return int */ public function getRuleId() { return $this->ruleId; } /** * @param string $taxClass */ public function setTaxClass($taxClass) { if (in_array($taxClass, $this->availableTaxClasses)) { $this->taxClass = $taxClass; } } /** * @return string */ public function getTaxClass() { return $this->taxClass; } public function isTaxAble() { return ! empty($this->taxClass); } /** * @param float $amount */ public function setAmount($amount) { $this->amount = $amount; } /** * @return float */ public function getAmount() { return $this->amount; } }