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

namespace Brandy\DynamicCss\Processors;

use Brandy\Utils\StylesDataHelpers;

/**
 * Fallback processor for normal/generic CSS variables
 */
class NormalVariableProcessor extends AbstractVariableProcessor {

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

	/**
	 * Process normal 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,
			function ( $data, $value ) {
				if ( ! is_string( $value ) && ! is_numeric( $value ) ) {
					return '';
				}
				return StylesDataHelpers::get_css_variable( $data['name'], $value );
			}
		);
	}
}
