<?php

namespace Lucent\Setup\Step;

use Lucent\Setup\Data\SetupStep;

class StorageLinkSetupStep implements IStep
{

    public function __invoke(): SetupStep
    {

        $storageDriver = config("filesystems.disks.lucent.driver");




        $name = "Storage Link";

        $instructions = <<<EOD
# If you have chosen to store your file locally then you have to generate a link to the public folder
# run:

php artisan storage:link
EOD;

        if($storageDriver !== "local"){
            return SetupStep::makeSuccess($name, $instructions);
        }

        $storageLinks = config("filesystems.links");
        $allLinksExist = array_reduce(array_keys($storageLinks),fn(bool $carry, string $link) => !$carry ? false : is_link($link) , true);

        return match ($allLinksExist) {
            true => SetupStep::makeSuccess($name, $instructions),
            false => SetupStep::makeFail($name, $instructions),
        };
    }
}