unitTtc = $unitPriceHt->subtract($unitDiscount)->add($unitTax); if ($quantity <= 0) { throw new \DomainException('Quantity must be greater than 0'); } if ($unitPriceHt->isNegative()) { throw new \DomainException('Unit price must be non-negative'); } if ($unitDiscount->isNegative()) { throw new \DomainException('Unit discount must be non-negative'); } if ($unitTax->isNegative()) { throw new \DomainException('Unit tax must be non-negative'); } if ($this->unitTtc->isNegative()) { throw new \DomainException('Unit TTC must be non-negative'); } if ($totalHt->isNegative()) { throw new \DomainException('Total HT must be non-negative'); } if ($totalDiscount->isNegative()) { throw new \DomainException('Total discount must be non-negative'); } if ($totalTax->isNegative()) { throw new \DomainException('Total tax must be non-negative'); } if ($totalTtc->isNegative()) { throw new \DomainException('Total TTC must be non-negative'); } } }