db = $db; } /** * @param string|array $details */ public function log(string $action, $details = null, ?int $userId = null): void { try { $this->db->query( "INSERT INTO audit_log (user_id, action, entity_type, details, ip_address) VALUES (?, ?, 'updater', ?, ?)", [ $userId, $action, is_string($details) ? $details : json_encode($details, JSON_UNESCAPED_UNICODE), $_SERVER['REMOTE_ADDR'] ?? null, ] ); } catch (\Throwable $e) { // bewusst still } } }