<?php
/*
 * Software Name: Eorisis Setup
 * Software URI: https://eorisis.com/shop/software/joomla/setup
 * Author: Eorisis
 * Author URI: https://eorisis.com
 * Copyright: Copyright (C) 2011-2025 EORISIS. All Rights Reserved.
 * License: GNU General Public License version 2; See https://eorisis.com/gpl
 * Terms of Service: https://eorisis.com/tos
 */
namespace eorisis_setup\framework\lib\core\cms;
\defined('_JEXEC') or die;

use EorisisFactory, JLoader;

if (!\class_exists('EorisisFactory', false))
{
	if (\version_compare(JVERSION, '3.8', '>='))
	{
		JLoader::registerAlias('EorisisFactory', '\\Joomla\\CMS\\Factory');
	}
	else
	{
		JLoader::registerAlias('EorisisFactory', 'JFactory');
	}
}

class config
{
	public function __construct() {}

	// -----------------------------------------------------

	public static function obj()
	{
		static $obj = null;
		if ($obj === null)
		{
			if (\version_compare(JVERSION, 4, '>='))
			{
				$obj = EorisisFactory::getContainer()->get('config');
			}
			else
			{
				$obj = EorisisFactory::getConfig();
			}
		}

		return $obj;
	}

	// --------------------------------------------------

	public static function offset(string $default = 'UTC')
	{
		static $val = null;
		if ($val !== null)
		{
			return $val;
		}

		$val = (string)self::obj()->get('offset');
		if (!$val)
		{
			$val = $default;
		}

		return $val;
	}
}
