<?php
/**
 * Finding severity.
 *
 * @package LocalGuardScanner
 */

namespace LocalGuardScanner\Domain\Detection;

/**
 * Maps numeric risk scores to stable labels.
 */
final class Severity {
	const INFO     = 'info';
	const LOW      = 'low';
	const MEDIUM   = 'medium';
	const HIGH     = 'high';
	const CRITICAL = 'critical';

	/**
	 * @param int $score Risk score.
	 * @return string
	 */
	public static function from_score( $score ) {
		$score = max( 0, min( 100, (int) $score ) );
		if ( $score >= 90 ) {
			return self::CRITICAL;
		}
		if ( $score >= 70 ) {
			return self::HIGH;
		}
		if ( $score >= 40 ) {
			return self::MEDIUM;
		}
		if ( $score >= 20 ) {
			return self::LOW;
		}
		return self::INFO;
	}
}
