<?php
/**
 * Provider-defined conflict merge contract.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Provider;

use ScheduledChanges\Field\FieldDefinition;

/**
 * Optional provider capability required by explicit merge conflict policies.
 */
interface MergeCapableFieldProvider {
	/**
	 * @param mixed $planned
	 * @param mixed $current
	 * @param mixed $desired
	 * @return mixed
	 * @throws \RuntimeException When merge inputs cannot be reconciled.
	 */
	public function mergeForExecution(
		ObjectContext $context,
		FieldDefinition $field,
		$planned,
		$current,
		$desired
	);

	/**
	 * @param mixed $before
	 * @param mixed $applied
	 * @param mixed $current
	 * @return mixed
	 * @throws \RuntimeException When rollback merge inputs cannot be reconciled.
	 */
	public function mergeForRollback(
		ObjectContext $context,
		FieldDefinition $field,
		$before,
		$applied,
		$current
	);
}
