<?php

declare(strict_types=1);

namespace App\Framework\View\Caching\Analysis;

enum CacheStrategy: string
{
    case FULL_PAGE = 'full_page';
    case COMPONENT = 'component';
    case FRAGMENT = 'fragment';
    case USER_AWARE = 'user_aware';
    case NO_CACHE = 'no_cache';

    public function getTtl(): int
    {
        return match($this) {
            self::FULL_PAGE => 3600,    // 1 hour
            self::COMPONENT => 1800,    // 30 minutes
            self::FRAGMENT => 900,      // 15 minutes
            self::USER_AWARE => 300,    // 5 minutes
            self::NO_CACHE => 0,        // No caching
        };
    }

    public function shouldCache(): bool
    {
        return $this !== self::NO_CACHE;
    }

    public function getDescription(): string
    {
        return match($this) {
            self::FULL_PAGE => 'Full page caching for static content',
            self::COMPONENT => 'Component-level caching for reusable parts',
            self::FRAGMENT => 'Fragment-based caching for mixed content',
            self::USER_AWARE => 'User-specific caching with short TTL',
            self::NO_CACHE => 'No caching for fully dynamic content',
        };
    }
}
