<?php
/**
 * WeCodeArt Framework.
 *
 * WARNING: This file is part of the core WeCodeArt Framework. DO NOT edit this file under any circumstances.
 * Please do all modifications in the form of a child theme.
 *
 * @package 	WeCodeArt Framework
 * @subpackage 	Support\Styles\Property\FontFamily
 * @copyright   Copyright (c) 2025, WeCodeArt Framework
 * @since 		5.0.0
 * @version		5.0.0
 */

namespace WeCodeArt\Support\Styles\Sanitize\Property;

defined( 'ABSPATH' ) || exit;

use WeCodeArt\Support\Styles\Sanitize\Property;

/**
 * Output for CSS properties.
 */
class Font extends Property {
	/**
	 * Modifies the value.
	 *
	 * @access protected
	 */
	protected function process_value() {
		$processed = $this->value;

		if ( is_array( $processed ) && isset( $processed['font-family'] ) ) {
			$processed = $processed['font-family'];
		}

		// Make sure the value is a string, if not, then early exit.
		if ( ! is_string( $processed ) ) {
			return;
		}

		// Hack for standard fonts.
		$processed = str_replace( '&quot;', '"', $processed );

		// Add double quotes if needed.
		if ( false !== strpos( $processed, ' ' ) && false === strpos( $processed, '"' ) ) {
			$processed = '"' . $processed . '"';
		}

		$this->value = html_entity_decode( $processed, ENT_QUOTES );
	}
}