<?php

/**
 * HoverEffectsAttributes handles hover effect related block styles and classes.
 *
 * @package Cryzel
 */

if (! defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

if (! class_exists('HoverEffectsAttributes')) {
    class HoverEffectsAttributes {

        /**
         * Get hover effect classes based on attributes.
         *
         * @param array $attrs Block attributes.
         * @return array
         */
        public static function get_classes($attrs) {
            $classes = [];

            if (! empty($attrs['cryzelHoverEffect']) && $attrs['cryzelHoverEffect'] !== 'none') {
                $classes[] = 'cryzel-hover-enabled';
                $classes[] = 'cryzel-hover-' . sanitize_html_class($attrs['cryzelHoverEffect']);
            }

            return $classes;
        }

        /**
         * Get hover effect inline styles based on attributes.
         *
         * @param array $attrs Block attributes.
         * @return array
         */
        public static function get_styles($attrs) {
            $styles = [];

            if (! empty($attrs['cryzelHoverIntensity'])) {
                $styles['--cryzel-intensity'] = esc_attr($attrs['cryzelHoverIntensity']);
            }

            if (! empty($attrs['cryzelHoverDuration'])) {
                $styles['--cryzel-duration'] = esc_attr($attrs['cryzelHoverDuration']) . 's';
            }

            if (! empty($attrs['cryzelHoverScale'])) {
                $styles['--cryzel-scale'] = esc_attr($attrs['cryzelHoverScale']);
            }

            return $styles;
        }
    }
}
