<?php
namespace Vidplex;

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class Init
 *
 * Entry point for initializing the plugin.
 *
 * Responsible for setting up core components, loading dependencies,
 * and bootstrapping the plugin functionality.
 */
final class Init {
	/**
	 * The single instance of the Init class.
	 *
	 * This static variable holds the single instance of the class and ensures
	 * that only one instance of the class is created (Singleton pattern).
	 *
	 * @var Init|null The single instance of the Init class or null if not instantiated.
	 */
	private static $instance = null;

	/**
	 * Retrieves the single instance of the Init class.
	 *
	 * This method implements the Singleton pattern, ensuring that only
	 * one instance of the Init class is created and used throughout
	 * the application. If the instance doesn't exist yet, it will be created.
	 *
	 * @return Init The single instance of the Init class.
	 */
	public static function get_instance() {
		if ( is_null( self::$instance ) ) {
			self::$instance = new self();
		}

		return self::$instance;
	}

	/**
	 * Init constructor.
	 *
	 * The constructor can be used to initialize resources, load configurations,
	 * or perform tasks necessary when the class is instantiated.
	 * In this case, resources can be loaded here.
	 *
	 * @return void
	 */
	private function __construct() {
		// Helpers
		\Vidplex\Helpers::get_instance();

		require_once VIDPLEX_PLUGIN_DIR . 'includes/functions.php';

		// Store setup.
		\Vidplex\Store::get_instance();

		// Rest API Init.
		\Vidplex\Rest_API::get_instance();

		// Load Admin area.
		\Vidplex\Admin::get_instance();

		// Resources.
		\Vidplex\Resources::get_instance();

		// Blocks.
		\Vidplex\Blocks::get_instance();
	}
}
