<?php
/**
 * @deprecated 2.5.0 Use ModuleManager.
 *
 * @package Kutby
 */

declare(strict_types=1);

namespace Kutby\Core;

use Kutby\Contracts\ModuleInterface;

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

/**
 * Class ModuleLoader
 */
final class ModuleLoader {

	/**
	 * @param array<int, ModuleInterface> $modules Modules.
	 */
	public function __construct( private array $modules ) {}

	/**
	 * @return void
	 */
	public function run(): void {
		$manager = new ModuleManager();
		foreach ( $this->modules as $module ) {
			$manager->add( $module );
		}
		// Re-run only added modules: register+boot manually for BC callers.
		foreach ( $this->modules as $module ) {
			$module->register();
		}
		foreach ( $this->modules as $module ) {
			$module->boot();
		}
	}
}
