<?php
/**
 * Run lifecycle status.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Domain\Run;

/**
 * String constants for RunStatus values.
 */
class RunStatus {

	public const PENDING                  = 'pending';
	public const VALIDATING               = 'validating';
	public const RUNNING                  = 'running';
	public const SUCCESSFUL               = 'successful';
	public const SUCCESSFUL_WITH_WARNINGS = 'successful_with_warnings';
	public const PARTIALLY_FAILED         = 'partially_failed';
	public const FAILED                   = 'failed';
	public const STALE                    = 'stale';
	public const DEAD_LETTER              = 'dead_letter';
	public const CANCELLED                = 'cancelled';
	public static function terminal( string $status ): bool {
		return in_array(
			$status,
			array(
				self::SUCCESSFUL,
				self::SUCCESSFUL_WITH_WARNINGS,
				self::PARTIALLY_FAILED,
				self::FAILED,
				self::STALE,
				self::DEAD_LETTER,
				self::CANCELLED,
			),
			true
		);
	}
}
