riskService->calculateCompanyRiskScore($companyId); // Store risk score $db = Database::getInstance(); $stmt = $db->prepare("INSERT INTO risk_scores (id, tenant_id, company_id, risk_type, score, reason) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->execute([ \Ramsey\Uuid\Uuid::uuid4()->toString(), $tenantId, $companyId, $analysis['level'], // risk_type = high/medium/low $analysis['score'], json_encode($analysis['factors'], JSON_UNESCAPED_UNICODE), // reason ]); } catch (Throwable $e) { echo "[!] Risk Analysis failed for company {$companyId}: " . $e->getMessage() . "\n"; throw $e; } } }