<?php

declare(strict_types=1);

namespace App\Framework\Deployment\Pipeline\ValueObjects;

/**
 * Deployment Pipeline Stage
 *
 * Represents a stage in the deployment pipeline (e.g., build, test, deploy).
 */
enum PipelineStage: string
{
    case BUILD = 'build';
    case TEST = 'test';
    case SECURITY_CHECK = 'security_check';
    case BACKUP = 'backup';
    case DEPLOY = 'deploy';
    case HEALTH_CHECK = 'health_check';
    case ROLLBACK = 'rollback';
    case CLEANUP = 'cleanup';

    public function getDescription(): string
    {
        return match ($this) {
            self::BUILD => 'Build application assets and dependencies',
            self::TEST => 'Run automated tests',
            self::SECURITY_CHECK => 'Perform security vulnerability scan',
            self::BACKUP => 'Create backup before deployment',
            self::DEPLOY => 'Deploy application to target environment',
            self::HEALTH_CHECK => 'Verify deployment health',
            self::ROLLBACK => 'Rollback to previous version',
            self::CLEANUP => 'Clean up temporary files and old versions',
        };
    }

    public function isCritical(): bool
    {
        return match ($this) {
            self::DEPLOY, self::ROLLBACK => true,
            default => false,
        };
    }
}
