<?php

declare(strict_types=1);

namespace App\Framework\Console\Security;

enum Permission: string
{
    case READ = 'read';
    case WRITE = 'write';
    case EXECUTE = 'execute';
    case ADMIN = 'admin';
    case ANALYTICS_READ = 'analytics.read';
    case ANALYTICS_WRITE = 'analytics.write';
    case HEALTH_CHECK = 'health.check';
    case SYSTEM_ADMIN = 'system.admin';
    case DATABASE_READ = 'database.read';
    case DATABASE_WRITE = 'database.write';
    case PERFORMANCE_READ = 'performance.read';
    case CACHE_MANAGE = 'cache.manage';

    public function getDescription(): string
    {
        return match ($this) {
            self::READ => 'Read access to commands and data',
            self::WRITE => 'Write access to modify data',
            self::EXECUTE => 'Execute commands',
            self::ADMIN => 'Administrative access',
            self::ANALYTICS_READ => 'Read analytics data',
            self::ANALYTICS_WRITE => 'Modify analytics data',
            self::HEALTH_CHECK => 'Run system health checks',
            self::SYSTEM_ADMIN => 'System administration',
            self::DATABASE_READ => 'Read database data',
            self::DATABASE_WRITE => 'Modify database data',
            self::PERFORMANCE_READ => 'Read performance metrics',
            self::CACHE_MANAGE => 'Manage cache operations',
        };
    }

    public function getCategory(): PermissionCategory
    {
        return match ($this) {
            self::READ, self::WRITE, self::EXECUTE => PermissionCategory::BASIC,
            self::ADMIN, self::SYSTEM_ADMIN => PermissionCategory::ADMIN,
            self::ANALYTICS_READ, self::ANALYTICS_WRITE => PermissionCategory::ANALYTICS,
            self::HEALTH_CHECK => PermissionCategory::MONITORING,
            self::DATABASE_READ, self::DATABASE_WRITE => PermissionCategory::DATABASE,
            self::PERFORMANCE_READ => PermissionCategory::PERFORMANCE,
            self::CACHE_MANAGE => PermissionCategory::SYSTEM,
        };
    }
}
