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

namespace Brandy\DynamicCss\Processors;

use Brandy\Utils\StylesDataHelpers;

/**
 * Processor for spacing CSS variables
 */
class SpacingVariableProcessor extends AbstractVariableProcessor {

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

	/**
	 * Process spacing 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_spacing_css_variable( $data['name'], $value )
		);
	}
}
