🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 13:19
This commit is contained in:
37
app/Core/helpers.php
Normal file
37
app/Core/helpers.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user