<?php

declare(strict_types=1);

namespace Drupal\flowdrop_stategraph\ApprovalGate;

/**
 * Enum representing approval gate statuses.
 *
 * @api
 */
enum ApprovalStatus: string {

  // Pending approval - waiting for human review.
  case Pending = "pending";

  // Approved - execution can continue.
  case Approved = "approved";

  // Rejected - execution should stop or take alternative path.
  case Rejected = "rejected";

  // Timed out - approval was not received within allowed time.
  case Timeout = "timeout";

  /**
   * Checks if this status allows execution to continue.
   *
   * @return bool
   *   TRUE if execution should continue.
   */
  public function allowsContinuation(): bool {
    return $this === self::Approved;
  }

  /**
   * Checks if this status represents a terminal state.
   *
   * @return bool
   *   TRUE if this is a final status.
   */
  public function isTerminal(): bool {
    return $this !== self::Pending;
  }

  /**
   * Gets a human-readable label for the status.
   *
   * @return string
   *   The status label.
   */
  public function label(): string {
    return match ($this) {
      self::Pending => "Pending Approval",
      self::Approved => "Approved",
      self::Rejected => "Rejected",
      self::Timeout => "Timed Out",
    };
  }

}
