<?php
declare(strict_types=1);

// 🛡️ Fetches settings and caches them, unless forced to refresh
function getSettings(bool $force_refresh = false): array {
    static $settings = null;
    
    // If it's null OR we force a refresh, query the database
    if ($settings === null || $force_refresh) {
        $db = new Database();
        $db->query("SELECT setting_key, setting_value FROM settings");
        $results = $db->resultSet();
        
        $settings = [];
        foreach($results as $row) {
            $settings[$row->setting_key] = $row->setting_value;
        }
    }
    
    return $settings;
}