<?php
/**
 * HappyFenceNG Total Enterprise Security Plugin
 * HAPPYWPRESS is a RazorVue Trademark.
 *
 * @package     HappyFenceNG
 * @developer   Simonluca Scillitani
 * @copyright   2025 RazorVue di Scillitani Simonluca
 * @link        https://razorvue.it
 * @author      RazorVue di Scillitani Simonluca
 * @brand       HappyWPress
 * @uri         https://happywpress.com
 * @set all
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**PHPCS -> code compliance: we put useful comments where needed.. */
class HappyFenceNGExecChain extends HappyFenceNGSystem {

	/**PHPCS -> code compliance: we put useful comments where needed..
	 *
	 * @var $chain is the chain .
	 */
	private static array $chain = array();

	/**PHPCS -> code compliance: we put useful comments where needed..
	 *
	 * @var $chain_number is the chain .
	 */
	private static int $chain_number = 1;
	/**PHPCS -> code compliance: we put useful comments where needed.. */
	public function __construct() {
		parent::__constructor( static::class );
		add_action( 'shutdown', array( $this, 'svc_chain_logger' ), PHP_INT_MAX );
	}

	/**PHPCS -> code compliance: we put useful comments where needed..
	 *
	 * @param string $subject is the module that is pushing the chain .
	 */
	public static function push_log( $subject ) {
		self::$chain[] = array(
			'subject'  => $subject,
			'priority' => self::$chain_number,
		);
		++self::$chain_number;
	}

	/**PHPCS -> code compliance: we put useful comments where needed.. */
	public function svc_chain_logger() {
		HappyFenceNGAlog::get_instance()->log(
			static::class . ' execution chain is-> ' . wp_json_encode( self::$chain ),
			HappyFenceNGSyslogFacility::DEBUG,
			HappyFenceNGSyslogSeverity::INFO
		);
	}
}
