<?php
/**
 * Dimension Variable Processor
 *
 * @package Brandy\DynamicCss\Processors
 */

namespace Brandy\DynamicCss\Processors;

use Brandy\Utils\StylesDataHelpers;

/**
 * Processor for dimension CSS variables
 */
class DimensionVariableProcessor extends AbstractVariableProcessor {

	/**
	 * Check if this processor supports the given type
	 *
	 * @param string $type Variable type.
	 * @return bool
	 */
	public function supports( string $type ): bool {
		return 'dimension' === $type;
	}

	/**
	 * Process dimension variable data
	 *
	 * @param array $variable_data Variable configuration.
	 * @return array Device-keyed CSS variables
	 */
	public function process( array $variable_data ): array {
		return $this->process_responsive(
			$variable_data,
			fn( $data, $value ) => StylesDataHelpers::get_dimension_css_variable( $data['name'], $value )
		);
	}
}
