55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
namespace NeotelApply;
|
|
|
|
use Dotenv\Dotenv;
|
|
|
|
class Configuration {
|
|
/** @var ?Dotenv $dotenv */
|
|
private static $dotenv = null;
|
|
|
|
/**
|
|
* Create or return a Dotenv instance
|
|
*
|
|
* @param string $mode
|
|
* @return Dotenv
|
|
*/
|
|
public static function load(string $mode = 'base'): Dotenv {
|
|
if (self::$dotenv === null) {
|
|
self::$dotenv = self::create($mode);
|
|
}
|
|
|
|
return self::$dotenv;
|
|
}
|
|
|
|
/**
|
|
* Construct a new Dotenv instance
|
|
*
|
|
* @param string $mode
|
|
* @return Dotenv
|
|
*/
|
|
private static function create(string $mode = 'base'): Dotenv {
|
|
// Construct and load Dotenv
|
|
$dotenv = Dotenv::createImmutable(IX_BASE);
|
|
$dotenv->load();
|
|
|
|
// Database shit
|
|
$dotenv->required('REDIS_URL')->notEmpty();
|
|
|
|
// Require an environment
|
|
$dotenv->required('APP_ENV')->allowedValues(['development', 'test', 'production']);
|
|
|
|
// Require a session cookie
|
|
$dotenv->required(IX_ENVBASE . '_SESSIONCOOKIE')->notEmpty();
|
|
|
|
// Pushover application and user keys
|
|
$dotenv->required(IX_ENVBASE . '_PUSHOVER_API_TOKEN')->notEmpty();
|
|
$dotenv->required(IX_ENVBASE . '_PUSHOVER_USER_KEYS')->notEmpty();
|
|
|
|
// Discord webhook URL
|
|
$dotenv->required(IX_ENVBASE . '_DISCORD_WEBHOOK_URL')->notEmpty();
|
|
|
|
return $dotenv;
|
|
}
|
|
}
|