transactions->run(function () use ($customerId, $billingUnitId): void { $billingUnit = $this->billingUnits->findForCustomer($customerId, $billingUnitId) ?? throw new BillingUnitNotFound($customerId, $billingUnitId); if ($this->usage->isBillingUnitInUse($billingUnitId)) { throw new BillingUnitInUse; } $this->billingUnits->delete($billingUnit); }); } }