<?php
/**
 * Contract every form-source adapter must implement.
 *
 * @package Leadite
 */

namespace Leadite\Capture;

defined( 'ABSPATH' ) || exit;

interface SourceAdapter {

	/**
	 * Unique source slug (e.g. 'cf7', 'elementor').
	 *
	 * @return string
	 */
	public function slug();

	/**
	 * Human-readable source label.
	 *
	 * @return string
	 */
	public function label();

	/**
	 * Whether the underlying form plugin is active on this site.
	 *
	 * @return bool
	 */
	public function is_available();

	/**
	 * Register hooks that capture submissions for this source.
	 * The hook callback collects raw payload, then delegates to normalize()
	 * and hands the resulting Lead to AdapterRegistry::store().
	 *
	 * @return void
	 */
	public function register();

	/**
	 * Convert a raw, source-specific payload into a normalized Lead.
	 * Pure transformation (no DB writes) so it can be unit-tested in isolation.
	 *
	 * @param array $raw Source-specific payload assembled by the capture hook.
	 * @return \Leadite\Storage\Lead
	 */
	public function normalize( array $raw );
}