<?php
/**
 * Internal event destination.
 *
 * @package Carticy\Conversions\Events
 */

declare(strict_types=1);

namespace Carticy\Conversions\Events;

use Carticy\Conversions\Domain\ConversionEvent;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Deterministic local sink used until real provider dispatch lands.
 */
final class InternalEventDestination implements EventDestinationInterface {

	public const KEY = 'internal_log';

	/**
	 * Get destination key.
	 *
	 * @return string
	 */
	public function key(): string {
		return self::KEY;
	}

	/**
	 * Emit an internal action for tests and later observers.
	 *
	 * @param ConversionEvent $event Canonical event.
	 * @return bool
	 */
	public function send( ConversionEvent $event ): bool {
		do_action( 'carticy_conversions_internal_event_created', $event, $this->key() );

		return true;
	}
}
