<?php

use PhpOption\None;
use PhpOption\Some;

if (!function_exists('some')) {
    /**
     * @template T
     * @param T $value
     * @return Some<T>
     */
    function some(mixed $value): Some
    {
        return new Some($value);
    }
}


if (!function_exists('none')) {
    function none(): None
    {
        return None::create();
    }
}

if (!function_exists('toArray')) {
    function toArray(mixed $data): array
    {
        return \json_decode(\json_encode($data), true);
    }
}


if (!function_exists('make_dir_r')) {
    function make_dir_r(string $path): void
    {
        is_dir($path) || mkdir($path, 0777, true);
    }
}


if (!function_exists('schemas_path')) {
    function schemas_path(): string
    {
        return storage_path("lucent/lucent.schemas.json");
    }
}

if (!function_exists('lucent_file')) {
    function lucent_file(\Lucent\Record\QueryRecord $record): string
    {
        $path = $record->_file->path;
        return   app()->make(\Lucent\Channel\ChannelService::class)->channel->disks[$record->_file->disk] ."/". $path;
    }
}

if (!function_exists('lucent_image')) {
    function lucent_image(\Lucent\Record\QueryRecord $record, string $template): string
    {
        $path = $record->_file->path;
        return   app()->make(\Lucent\Channel\ChannelService::class)->channel->disks[$record->_file->disk] . "/templates/$template/$path";
    }
}


