<?php

namespace Modules\SmartStorage\Entities\Drivers;

use League\Flysystem\FilesystemAdapter;
use League\Flysystem\Local\LocalFilesystemAdapter;
use Modules\SmartStorage\Entities\Contracts\StorageBackendDriver;
use Modules\SmartStorage\Entities\SsSetting;

/**
 * The "do nothing special" backend: a plain local adapter rooted at the legacy
 * public upload path. While this backend is active the provider performs no disk
 * swap at all, so the framework behaves exactly as before installing the module.
 * It also serves as the safe fallback when a configured backend is unavailable.
 */
class LaravelDefaultBackendDriver implements StorageBackendDriver
{
    public function key(): string
    {
        return 'laravel-default';
    }

    public function label(): string
    {
        return 'Laravel default (public/uploads, no changes)';
    }

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

    public function validateConfig(SsSetting $settings): array
    {
        return [];
    }

    public function makeAdapter(SsSetting $settings): FilesystemAdapter
    {
        $root = config('filesystems.disks.local.root', public_path('uploads'));

        return new LocalFilesystemAdapter($root);
    }
}
