<?php
/**
 * Scheduled end behavior.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Rollback;

/**
 * One operation's selected behavior for a separately compiled end version.
 */
final class EndBehavior {
	private string $type;
	/**
	 * @var mixed
	 */
	private $value = null;
	/**
	 * @param mixed $value
	 */
	private function __construct( string $type, $value = null ) {
		$this->type  = $type;
		$this->value = $value;
	}

	public static function restore(): self {
		return new self( EndBehaviorType::RESTORE_PRE_LAUNCH );
	}

	/**
	 * @param mixed $value
	 */
	public static function apply( $value ): self {
		return new self( EndBehaviorType::APPLY_SPECIFIC_VALUE, $value );
	}

	public static function keep(): self {
		return new self( EndBehaviorType::KEEP_LAUNCH_VALUE );
	}

	public function type(): string {
		return $this->type;
	}

	/**
	 * @return mixed
	 */
	public function value() {
		return $this->value;
	}
}
