38 lines
786 B
PHP
38 lines
786 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
if (!function_exists('config')) {
|
|
/**
|
|
* Get a configuration value using dot notation.
|
|
* Example: config('app.name')
|
|
*/
|
|
function config(string $key, mixed $default = null): mixed
|
|
{
|
|
$configs = \App\Core\Application::$config;
|
|
|
|
if ($configs === null) {
|
|
return $default;
|
|
}
|
|
|
|
$parts = explode('.', $key);
|
|
$value = $configs;
|
|
|
|
foreach ($parts as $part) {
|
|
if (!isset($value[$part])) {
|
|
return $default;
|
|
}
|
|
$value = $value[$part];
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
}
|
|
|
|
if (!function_exists('env')) {
|
|
function env(string $key, mixed $default = null): mixed
|
|
{
|
|
return $_ENV[$key] ?? $default;
|
|
}
|
|
}
|