calculateTotal(); } /** * Used to set the line item's values so that the total and tax add up correctly. * * @param int $price * @param int $unitTax * @param int $quantity * * @return $this */ public function calculate($price, $unitTax, $quantity = 0) { $this->Tax = $unitTax * $quantity; $this->Total = $this->Tax + ($quantity * $price); return $this; } /** * @return $this */ private function calculateTotal() { if (isset($this->Quantity) && isset($this->UnitCost)) { if (isset($this->Tax)) { $this->Total = $this->Tax + ($this->Quantity * $this->UnitCost); } else { $this->Total = $this->Quantity * $this->UnitCost; } } return $this; } }