tax_data = $tax_data; } public function tax(): self { $this->tax_name1 = 21; $this->tax_rate1 = "VAT"; return $this; } public function taxByType(?int $product_tax_type): self { if(!$product_tax_type) return $this; match($product_tax_type){ Product::PRODUCT_TAX_EXEMPT => $this->taxExempt(), Product::PRODUCT_TYPE_DIGITAL => $this->taxDigital(), Product::PRODUCT_TYPE_SERVICE => $this->taxService(), Product::PRODUCT_TYPE_SHIPPING => $this->taxShipping(), Product::PRODUCT_TYPE_PHYSICAL => $this->taxPhysical(), default => $this->default(), }; return $this; } public function taxExempt(): self { $this->tax_name1 = ''; $this->tax_rate1 = 0; return $this; } public function taxDigital(): self { $this->tax(); return $this; } public function taxService(): self { if($this->tax_data->txbService == 'Y') $this->tax(); return $this; } public function taxShipping(): self { if($this->tax_data->txbFreight == 'Y') $this->tax(); return $this; } public function taxPhysical(): self { $this->tax(); return $this; } public function default(): self { $this->tax_name1 = ''; $this->tax_rate1 = 0; return $this; } }