Files
Php-Template/src/Helpers/Env.php
Ron Rise 5542ad1e75
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 1m42s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 1m38s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m5s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m44s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 2m28s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m27s
chore: added documentation (#16)
Reviewed-on: #16
Co-authored-by: Ron Rise <ron@siteworxpro.com>
Co-committed-by: Ron Rise <ron@siteworxpro.com>
2025-11-13 04:14:13 +00:00

31 lines
689 B
PHP

<?php
declare(strict_types=1);
namespace Siteworxpro\App\Helpers;
/**
* Class Env
* @package 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,
};
}
}