cleanup
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Channel;
|
||||
|
||||
|
||||
use Lucent\Validator\Validator;
|
||||
|
||||
class PreviewTarget
|
||||
{
|
||||
function __construct(
|
||||
public readonly string $label,
|
||||
public readonly string $url,
|
||||
)
|
||||
{
|
||||
Validator::single("label", $label, "required|min:2|max:50");
|
||||
Validator::single("url", $url, "required|url");
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): PreviewTarget
|
||||
{
|
||||
|
||||
return new PreviewTarget(
|
||||
label: $data["label"],
|
||||
url: $data["url"],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Edge;
|
||||
|
||||
|
||||
final class QueryEdge
|
||||
{
|
||||
public function __construct(
|
||||
public string $fromSchema,
|
||||
public string $from,
|
||||
public string $schema,
|
||||
public string $field,
|
||||
public string $to,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Primitive;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Support\Collection<int|string, string>
|
||||
*/
|
||||
final class StringCollection extends Collection
|
||||
{
|
||||
|
||||
public function __construct(
|
||||
string ...$array
|
||||
) {
|
||||
parent::__construct($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
**/
|
||||
public function toArray(): array
|
||||
{
|
||||
return collect($this)->values()->toArray();
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): StringCollection
|
||||
{
|
||||
return new StringCollection(...$data);
|
||||
}
|
||||
|
||||
public static function fromDB(string $data): StringCollection
|
||||
{
|
||||
return new StringCollection(...\json_decode($data,true));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Support;
|
||||
|
||||
/**
|
||||
* An in-memory memoizer that keeps the cached values around for the lifetime of this instance.
|
||||
*/
|
||||
class Memoize
|
||||
{
|
||||
/**
|
||||
* The saved results
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private array $cache = [];
|
||||
|
||||
/**
|
||||
* $cacheTime is ignored - this will keep the results around for the lifetime of this instance.
|
||||
*
|
||||
* @see Memoize::memoizeCallable
|
||||
*
|
||||
* @param string $key
|
||||
* @param callable $compute
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function memoizeCallable(string $key, callable $compute) :mixed
|
||||
{
|
||||
if (array_key_exists($key, $this->cache)) {
|
||||
return $this->cache[$key];
|
||||
}
|
||||
|
||||
$result = $compute();
|
||||
$this->cache[$key] = $result;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user