TODO: Replace stubs

This commit is contained in:
2025-04-25 19:42:16 -04:00
commit 9bdecb1455
16 changed files with 2996 additions and 0 deletions

32
src/Helpers/Config.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Siteworxpro\App\Helpers;
use Psr\Log\LogLevel;
use Siteworxpro\App\Facades\Config as FacadeConfig;
class Config
{
private const array DEFAULTS = [
FacadeConfig::DB_DRIVER => 'pgsql',
FacadeConfig::DB_HOST => 'localhost',
FacadeConfig::DB_DATABASE => 'siteworx',
FacadeConfig::DB_USER => 'siteworx',
FacadeConfig::DB_PASSWORD => 'password',
FacadeConfig::LOG_LEVEL => LogLevel::DEBUG,
FacadeConfig::HTTP_PORT => '9501',
FacadeConfig::DEV_MODE => true,
];
/**
* @param string $key
* @param string $castTo
* @return string|int|bool|float
*/
public function get(string $key, string $castTo = 'string'): string|int|bool|float
{
return Env::get($key, self::DEFAULTS[$key] ?? null, $castTo);
}
}

26
src/Helpers/Env.php Normal file
View 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,
};
}
}