<?php
/**
 * Recording plan compilation result.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Application;

use ScheduledChanges\Domain\Shared\Uuid;

/**
 * Identifies the immutable launch version created by compilation.
 */
final class RecordingPlanCompilationResult {
	private Uuid $launch_uuid;
	private int $launch_id;
	private int $version_id;
	private int $selected_change_count;

	/**
	 * Creates a recording compilation result.
	 */
	public function __construct( Uuid $launch_uuid, int $launch_id, int $version_id, int $selected_change_count ) {
		if ( $launch_id <= 0 || $version_id <= 0 || $selected_change_count <= 0 ) {
			throw new \InvalidArgumentException( 'Compiled recordings require a launch, version, and selected changes.' );
		}

		$this->launch_uuid           = $launch_uuid;
		$this->launch_id             = $launch_id;
		$this->version_id            = $version_id;
		$this->selected_change_count = $selected_change_count;
	}

	/**
	 * Returns the public launch UUID.
	 */
	public function launchUuid(): Uuid {
		return $this->launch_uuid;
	}

	/**
	 * Returns the persisted launch ID.
	 */
	public function launchId(): int {
		return $this->launch_id;
	}

	/**
	 * Returns the persisted launch version ID.
	 */
	public function versionId(): int {
		return $this->version_id;
	}

	/**
	 * Returns the selected change count compiled into the plan.
	 */
	public function selectedChangeCount(): int {
		return $this->selected_change_count;
	}
}
