You've already forked Traefik-Redis-Api
done. going to bed now.
This commit is contained in:
26
src/Helpers/Env.php
Normal file
26
src/Helpers/Env.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\App\Helpers;
|
||||
|
||||
abstract class Env
|
||||
{
|
||||
/**
|
||||
* @param string $key
|
||||
* @param null $default
|
||||
* @param string $castTo
|
||||
* @return float|bool|int|string
|
||||
*/
|
||||
public static function get(string $key, $default = null, string $castTo = 'string'): float | bool | int | string
|
||||
{
|
||||
$env = getenv($key) !== false ? getenv($key) : $default;
|
||||
|
||||
return match ($castTo) {
|
||||
'bool', 'boolean' => (bool) $env,
|
||||
'int', 'integer' => (int) $env,
|
||||
'float' => (float) $env,
|
||||
default => (string) $env,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user