Files
lucent-laravel/src/macros.php
T
2023-10-06 13:07:09 +03:00

48 lines
798 B
PHP

<?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");
}
}