<?php
/**
 * Selected execution and snapshot services.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Bootstrap;

use ScheduledChanges\Execution\ExecutionModule;
use ScheduledChanges\Execution\ExecutionServices;
use ScheduledChanges\Snapshot\SnapshotServices;

/**
 * Keeps execution composition state out of the root boot method.
 */
final class CoreExecutionRuntime {
	private ?ExecutionModule $module;
	private ?ExecutionServices $services;
	private ?SnapshotServices $snapshots;

	/**
	 * Creates the selected execution runtime.
	 */
	public function __construct(
		?ExecutionModule $module,
		?ExecutionServices $services,
		?SnapshotServices $snapshots
	) {
		$this->module    = $module;
		$this->services  = $services;
		$this->snapshots = $snapshots;
	}

	/**
	 * Returns the execution module when selected.
	 */
	public function module(): ?ExecutionModule {
		return $this->module;
	}

	/**
	 * Returns execution services when selected.
	 */
	public function services(): ?ExecutionServices {
		return $this->services;
	}

	/**
	 * Returns snapshot services when execution or rollback needs them.
	 */
	public function snapshots(): ?SnapshotServices {
		return $this->snapshots;
	}
}
