timezone = ini_get('date.timezone') ?: 'UTC'; } public static function createFromArray(array $configArray): self { $config = new self(); foreach ($configArray as $key => $value) { assert(property_exists($config, $key)); if ($value !== null) { $config->$key = $value; } } return $config; } public function getAppTitle(): string { return $this->appTitle; } public function getAppEnvironment(): string { return $this->environment; } public function isDebugMode(): bool { return $this->debug; } public function getTimezone(): string { return $this->timezone; } public function getDateTimeFormat(): string { // Specify datetime format (https://www.php.net/manual/en/datetime.format.php) // Default value "r": RFC 2822 formatted date (Thu, 21 Dec 2000 16:01:07 +0200) return $this->dateTimeFormat; } public function getTwigCacheDir(): ?string { if (empty($this->twigCacheDir)) { return null; } elseif (substr($this->twigCacheDir, 0, 1) === '/') { // Absolute path return $this->twigCacheDir; } else { // Relative path return ROOT_DIR . '/' . $this->twigCacheDir; } } public function getTwigSettings(): array { return [ 'cache' => $this->getTwigCacheDir() ?: false, 'debug' => $this->isDebugMode(), 'strict_variables' => $this->isDebugMode(), ]; } public function getDatabaseSettings(): array { return [ 'host' => $this->databaseHost, 'port' => $this->databasePort, 'dbname' => $this->databaseName, 'username' => $this->databaseUsername, 'password' => $this->databasePassword, ]; } }