<?php

declare(strict_types=1);

namespace App\Framework\Retry;

/**
 * Retry Strategy Type Enumeration
 *
 * Defines different retry strategy types for categorization and factory creation
 */
enum RetryStrategyType: string
{
    case NONE = 'none';
    case FIXED = 'fixed';
    case LINEAR = 'linear';
    case EXPONENTIAL = 'exponential';
    case FIBONACCI = 'fibonacci';
    case CUSTOM = 'custom';

    public function getDescription(): string
    {
        return match ($this) {
            self::NONE => 'No retries attempted',
            self::FIXED => 'Fixed delay between retries',
            self::LINEAR => 'Linear increase in delay between retries',
            self::EXPONENTIAL => 'Exponential backoff between retries',
            self::FIBONACCI => 'Fibonacci sequence delay pattern',
            self::CUSTOM => 'Custom retry strategy implementation'
        };
    }

    /**
     * Get the corresponding strategy class name
     */
    public function getStrategyClassName(): ?string
    {
        return match ($this) {
            self::NONE => null, // No strategy class needed
            self::FIXED => 'App\\Framework\\Retry\\Strategies\\FixedRetryStrategy',
            self::LINEAR => 'App\\Framework\\Retry\\Strategies\\LinearDelayStrategy',
            self::EXPONENTIAL => 'App\\Framework\\Retry\\Strategies\\ExponentialBackoffStrategy',
            self::FIBONACCI => null, // Would need to be implemented
            self::CUSTOM => null // User-provided
        };
    }

    /**
     * Check if this strategy type is available in the framework
     */
    public function isAvailable(): bool
    {
        $className = $this->getStrategyClassName();

        return $className === null || class_exists($className);
    }
}
