<?php

namespace App\Support;

enum TenantRole: string
{
    case Owner = 'owner';
    case Manager = 'manager';
    case Operator = 'operator';
    case Readonly = 'readonly';

    public function canSync(): bool
    {
        return match ($this) {
            self::Owner,
            self::Manager,
            self::Operator => true,
            self::Readonly => false,
        };
    }

    public function canManageBackupSchedules(): bool
    {
        return match ($this) {
            self::Owner,
            self::Manager => true,
            default => false,
        };
    }

    public function canRunBackupSchedules(): bool
    {
        return match ($this) {
            self::Owner,
            self::Manager,
            self::Operator => true,
            self::Readonly => false,
        };
    }

    public function canViewProviders(): bool
    {
        return true;
    }

    public function canManageProviders(): bool
    {
        return match ($this) {
            self::Owner,
            self::Manager => true,
            default => false,
        };
    }

    public function canRunProviderOperations(): bool
    {
        return match ($this) {
            self::Owner,
            self::Manager,
            self::Operator => true,
            self::Readonly => false,
        };
    }
}
