<?php
/**
 * Admin coordinator.
 *
 * @package TrustLens\Admin
 * @since   1.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Coordinates the modular admin services.
 *
 * @since 1.1.5
 */
class TrustLens_Admin {

	/**
	 * Single instance.
	 *
	 * @var TrustLens_Admin|null
	 */
	private static ?TrustLens_Admin $instance = null;

	/**
	 * Registered admin services.
	 *
	 * @var array<int,object>
	 */
	private array $services = array();

	/**
	 * Get instance.
	 *
	 * @since 1.0.0
	 * @return TrustLens_Admin
	 */
	public static function instance(): TrustLens_Admin {
		if ( null === self::$instance ) {
			self::$instance = new self();
		}

		return self::$instance;
	}

	/**
	 * Constructor.
	 *
	 * @since 1.0.0
	 */
	private function __construct() {
		$this->services = array(
			new TrustLens_Admin_Pages(),
			new TrustLens_Admin_Settings(),
			new TrustLens_Admin_Notices(),
			new TrustLens_Admin_Ajax(),
		);

		foreach ( $this->services as $service ) {
			if ( method_exists( $service, 'register_hooks' ) ) {
				$service->register_hooks();
			}
		}
	}
}
