<?php

declare(strict_types=1);

namespace App\Framework\Discovery\ValueObjects;

/**
 * Configurable scan strategies for different use cases
 */
enum ScanStrategy: string
{
    case DEPTH_FIRST = 'depth_first';
    case BREADTH_FIRST = 'breadth_first';
    case PRIORITY_BASED = 'priority_based';
    case MEMORY_OPTIMIZED = 'memory_optimized';
    case PERFORMANCE_OPTIMIZED = 'performance_optimized';
    case FIBER_PARALLEL = 'fiber_parallel';

    public function getDescription(): string
    {
        return match($this) {
            self::DEPTH_FIRST => 'Scan deeply into directory structures first',
            self::BREADTH_FIRST => 'Scan all directories at same level before going deeper',
            self::PRIORITY_BASED => 'Scan important directories first (src, app, etc.)',
            self::MEMORY_OPTIMIZED => 'Optimize for low memory usage, process small files first',
            self::PERFORMANCE_OPTIMIZED => 'Optimize for speed, use parallel processing',
            self::FIBER_PARALLEL => 'Use Fibers for parallel directory processing',
        };
    }

    /**
     * Get recommended chunk size for this strategy
     */
    public function getRecommendedChunkSize(): int
    {
        return match($this) {
            self::MEMORY_OPTIMIZED => 50,
            self::PERFORMANCE_OPTIMIZED => 200,
            default => 100,
        };
    }

    /**
     * Should use parallel processing?
     */
    public function useParallelProcessing(): bool
    {
        return match($this) {
            self::PERFORMANCE_OPTIMIZED, self::FIBER_PARALLEL => true,
            default => false,
        };
    }

    /**
     * Should use Fiber-based parallel processing?
     */
    public function useFiberProcessing(): bool
    {
        return $this === self::FIBER_PARALLEL;
    }

    /**
     * Get priority directories for PRIORITY_BASED strategy
     */
    public function getPriorityDirectories(): array
    {
        return [
            'src',
            'app',
            'lib',
            'core',
            'domain',
            'application',
            'infrastructure',
            'tests',
            'spec',
        ];
    }
}
