<?php
/**
 * Launch planning and validation module boundary.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Validation;

use ScheduledChanges\Field\FieldRegistry;
use ScheduledChanges\Provider\ProviderRegistry;

/**
 * Builds the provider-neutral launch planning and validation services.
 */
final class ValidationModule {
	public const MODULE_ID = 'scheduled-changes-validation';

	public function createServices(
		ProviderRegistry $providers,
		FieldRegistry $fields,
		?ValidationEnvironment $environment = null,
		?OperationGraphValidator $graphs = null
	): ValidationServices {
		$environment ??= new WordPressValidationEnvironment();
		$graphs      ??= new OperationGraphValidator();
		$validator     = new PlanValidator( $providers, $fields, $environment, $graphs );

		return new ValidationServices(
			$validator,
			new DryRunService( $validator ),
			$environment,
			$graphs
		);
	}
}
