<?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\controller;
\defined('_JEXEC') or die;

use eorisis_setup\framework\lib\core\model\clean;

class request
{
	public function __construct() {}

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

	public static function header(string $key, $default = '')
	{
		if (isset($_SERVER[$key]))
		{
			return $_SERVER[$key];
		}

		// Returns the value of the environment variable varname,
		// or FALSE if the environment variable varname does not exist
		$val = \getenv($key);
		if ($val !== false)
		{
			return $val;
		}

		return $default;
	}

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

	public static function server_hostname() : string
	{
		$string = clean::uri(self::header('SERVER_NAME'));
		if ($string)
		{
			return $string;
		}

		return clean::uri(self::header('HTTP_HOST'));
	}
}
