<?php
/**
 * Sub Tab Page Details Class
 *
 * This class is used to store and manage sub-tab page details including page titles,
 * menu titles, tab names, view files, IDs, CSS, and navigation settings.
 *
 * @package miniorange-sms-order-notification-otp-verification/objects
 */

namespace WCSMSOTP\Objects;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Sub Tab Page Details Class
 *
 * This class is used to store and manage sub-tab page details including page titles,
 * menu titles, tab names, view files, IDs, CSS, and navigation settings.
 */
if ( ! class_exists( 'SubtabPageDetails' ) ) {
	/**
	 * Sub Tab Page Details Class
	 *
	 * This class is used to store and manage sub-tab page details including page titles,
	 * menu titles, tab names, view files, IDs, CSS, and navigation settings.
	 */
	class SubtabPageDetails {

		/**
		 * Constructor.
		 *
		 * Initializes sub-tab page details with the provided parameters.
		 *
		 * @param string $page_title Page title.
		 * @param string $menu_title Menu title.
		 * @param string $tab_name Tab name.
		 * @param string $view View file path.
		 * @param string $id ID of the subtab.
		 * @param string $css CSS to be applied to the navbar.
		 * @param bool   $show_in_nav Whether to show the tab in navbar.
		 */
		public function __construct( $page_title, $menu_title, $tab_name, $view, $id, $css = '', $show_in_nav = true ) {
			if ( ! is_string( $page_title ) || ! is_string( $menu_title ) || ! is_string( $tab_name ) || ! is_string( $view ) || ! is_string( $id ) ) {
				return;
			}
			if ( ! is_string( $css ) ) {
				$css = '';
			}
			if ( ! is_bool( $show_in_nav ) ) {
				$show_in_nav = true;
			}

			$this->page_title  = sanitize_text_field( $page_title );
			$this->menu_title  = sanitize_text_field( $menu_title );
			$this->tab_name    = sanitize_text_field( $tab_name );
			$this->view        = sanitize_text_field( $view );
			$this->id          = sanitize_html_class( $id );
			$this->css         = wp_kses_post( $css );
			$this->show_in_nav = $show_in_nav;
		}

		/**
		 * The page title
		 *
		 * @var string
		 */
		public $page_title;

		/**
		 * The menu title
		 *
		 * @var string
		 */
		public $menu_title;

		/**
		 * Tab Name
		 *
		 * @var string
		 */
		public $tab_name;

		/**
		 * The php page having the view
		 *
		 * @var string
		 */
		public $view;

		/**
		 * The ID attribute of the Tab
		 *
		 * @var string
		 */
		public $id;

		/**
		 * The Attribute which decides if this page should be shown
		 * in the Navbar
		 *
		 * @var bool
		 */
		public $show_in_nav;

		/**
		 * The inline css to be applied to the navbar
		 *
		 * @var string
		 */
		public $css;
	}
}
