<?php
/**
 * Snapshot module boundary.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Snapshot;

use ScheduledChanges\Provider\ProviderRegistry;
use ScheduledChanges\Repository\SnapshotRepository;
use ScheduledChanges\Repository\WpdbSnapshotRepository;

/**
 * Builds snapshot capture services shared by execution and rollback.
 */
final class SnapshotModule {
	/**
	 * Creates snapshot services.
	 */
	public function createServices(
		ProviderRegistry $providers,
		?SnapshotRepository $snapshots = null
	): SnapshotServices {
		$snapshots ??= new WpdbSnapshotRepository();

		return new SnapshotServices(
			$snapshots,
			new SnapshotCoordinator( $providers, $snapshots )
		);
	}
}
