<?php
declare(strict_types=1);

namespace Ekesto\CacheInvalidator\Core\Elementor;

/**
 * Shared Elementor document classification values.
 */
final class ElementorDocumentClassification
{
    public const STRUCTURAL_CONTAINER = 'STRUCTURAL_CONTAINER';
    public const PRESENTATION_TEMPLATE = 'PRESENTATION_TEMPLATE';
    public const NON_STRUCTURAL = 'NON_STRUCTURAL';
    public const UNKNOWN = 'UNKNOWN';

    /**
     * Normalize an arbitrary classification value into a known shared value.
     *
     * @param string $classification Raw classification value.
     * @return string Normalized classification value.
     */
    public static function normalize(string $classification): string
    {
        $classification = trim($classification);

        if (in_array($classification, self::values(), true)) {
            return $classification;
        }

        return self::UNKNOWN;
    }

    /**
     * Return all supported classification values.
     *
     * @return string[]
     */
    public static function values(): array
    {
        return [
            self::STRUCTURAL_CONTAINER,
            self::PRESENTATION_TEMPLATE,
            self::NON_STRUCTURAL,
            self::UNKNOWN,
        ];
    }
}
