<?php

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

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['eryndoHoverEffect']) && $attrs['eryndoHoverEffect'] !== 'none') {
                $classes[] = 'eryndo-hover-enabled';
                $classes[] = 'eryndo-hover-' . sanitize_html_class($attrs['eryndoHoverEffect']);
            }

            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['eryndoHoverIntensity'])) {
                $styles['--eryndo-intensity'] = esc_attr($attrs['eryndoHoverIntensity']);
            }

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

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

            return $styles;
        }
    }
}
