<?php

declare(strict_types=1);

namespace Drupal\flowdrop_workflow\Diagnostic;

/**
 * The severity of a workflow {@see Finding}.
 *
 * Error findings reflect rules that block a save on the hot path (a workflow
 * carrying them is structurally broken); warnings and info are advisory — the
 * runtime tolerates them but the author probably wants to know.
 */
enum Severity: string {

  case Error = 'error';
  case Warning = 'warning';
  case Info = 'info';

  /**
   * A stable sort weight, most severe first.
   *
   * @return int
   *   Lower sorts earlier (Error before Warning before Info).
   */
  public function weight(): int {
    return match ($this) {
      self::Error => 0,
      self::Warning => 1,
      self::Info => 2,
    };
  }

}
