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

class form
{
	public function __construct() {}

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

	public static function radio(string $name, array $args = []) : string
	{
		$args = \array_replace([
			'id' => '',
			'value' => '',
			'title' => '',
			'class' => '',
			'autocomplete' => 'off',
			'checked' => false
		], $args);

		$arr = \array_filter([
			$args['title'] ? 'title="'.$args['title'].'"' : '',
			$args['checked'] ? 'checked' : '',
		]);
		return '<input type="radio" name="'.$name.'" id="'.$args['id'].'" value="'.$args['value'].'" class="'.$args['class'].'" autocomplete="'.$args['autocomplete'].'" '.\implode(' ', $arr).'>';
	}

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

	public static function hidden(string $name, array $args = []) : string
	{
		$args = \array_replace([
			'id' => '',
			'value' => ''
		], $args);

		$arr = \array_filter([
			$args['id'] ? 'id="'.$args['id'].'"' : '',
			$args['value'] ? 'value="'.$args['value'].'"' : ''
		]);
		return '<input type="hidden" name="'.$name.'" '.\implode(' ', $arr).'>';
	}

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

	public static function btn_size_class() : string
	{
		static $val = null;
		if ($val !== null)
		{
			return $val;
		}

		$val = '';
		if (\version_compare(JVERSION, 4, '<'))
		{
			if (\eorisis_setup\framework\lib\core\app\user::param('ui_btns_size', 'medium') == 'small')
			{
				$val = ' btn-group-yesno';
			}
		}

		return $val;
	}
}
