<?php
/**
 * Record Changes engine module boundary.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Recording;

use ScheduledChanges\Lock\LockManager;
use ScheduledChanges\Repository\RecordingSessionRepository;

/**
 * Builds generic recording services selected by the active module graph.
 */
final class RecordingModule {
	public const MODULE_ID = 'scheduled-changes-recording';

	/**
	 * Creates recording engine services from registered adapters and compilers.
	 *
	 * @param RecordingSessionRepository      $sessions Recording session repository.
	 * @param RecordingWorkspaceAdapter       $workspace Recording workspace adapter/router.
	 * @param RecordingLaunchCompilerContract $compiler Recording launch compiler/router.
	 * @param LockManager                     $locks Lock manager.
	 * @param RecordingDiagnosticBuilder|null $diagnostics Recording diagnostics builder.
	 */
	public function createServices(
		RecordingSessionRepository $sessions,
		RecordingWorkspaceAdapter $workspace,
		RecordingLaunchCompilerContract $compiler,
		LockManager $locks,
		?RecordingDiagnosticBuilder $diagnostics = null
	): RecordingServices {
		return new RecordingServices(
			new RecordingService( $sessions, $workspace, $compiler, $locks, $diagnostics )
		);
	}
}
