<?php

$appLocalConfig = [];
$appLocalConfigFile = __DIR__ . '/config.local.inc.php';
if (is_file($appLocalConfigFile)) {
    $loadedConfig = require $appLocalConfigFile;
    if (is_array($loadedConfig)) {
        $appLocalConfig = $loadedConfig;
    }
}
if (!function_exists('app_config')) {
    function app_config(string $key, mixed $default = null): mixed
    {
        global $appLocalConfig;
        $environmentValue = getenv($key);
        if ($environmentValue !== false && $environmentValue !== '') {
            return $environmentValue;
        }
        return $appLocalConfig[$key] ?? $default;
    }
}
