<?php
/**
 * Schema validation severity helpers.
 *
 * @package SEOvaultSEO\Schema\Validation
 */

namespace SEOvaultSEO\Schema\Validation;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Defines the supported validation severities and their display order.
 */
class Severity {

	const ERROR          = 'error';
	const WARNING        = 'warning';
	const RECOMMENDATION = 'recommendation';
	const INFO           = 'info';

	/**
	 * Get all supported severity values in descending importance.
	 *
	 * @return string[]
	 */
	public static function all() {
		return array(
			self::ERROR,
			self::WARNING,
			self::RECOMMENDATION,
			self::INFO,
		);
	}

	/**
	 * Determine whether a severity is supported.
	 *
	 * @param string $severity Severity value.
	 * @return bool
	 */
	public static function is_valid( $severity ) {
		return in_array( $severity, self::all(), true );
	}

	/**
	 * Get the stable sort priority for a severity.
	 *
	 * @param string $severity Severity value.
	 * @return int
	 */
	public static function get_priority( $severity ) {
		$priorities = array(
			self::ERROR          => 0,
			self::WARNING        => 1,
			self::RECOMMENDATION => 2,
			self::INFO           => 3,
		);

		return $priorities[ $severity ] ?? count( $priorities );
	}
}
