<?php
/**
 * Formats a field name.
 *
 * @package EaLab\WP_Deployer
 */

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

/**
 * Requires.
 */
require_once __DIR__ . '/../utility/component-based-object.php';

use EaLab\WP_Deployer\vendor\Ealab\Deployer\Exception\WpDeployException;
use EaLab\WP_Deployer\vendor\Ealab\Deployer\Tracking\TrackingManager;

function deploy_sync_content__field_name( string $full_field_name, array $context ): string {
	$tracking_manager = deploy_sync_content__get_root_cbo( TrackingManager::class );

	if ( empty( $tracking_manager ) ) {
		throw new WpDeployException( esc_html( 'The Deploy & Sync Content plugin is not ready; TrackingManager is not ready.' ) );
	}

	$html = '<div class="deploy_sync_content__field_name">';

	$html .= '<div class="prettified-field-name">' . esc_html( $tracking_manager->prettifyFieldName( $full_field_name ) ) . '</div>';
	$html .= '<div class="full-field-name">' . esc_html( $full_field_name ) . '</div>';

	$html .= '</div>';

	return $html;
}
