This commit is contained in:
2023-10-17 18:56:37 +03:00
parent d9736b29a4
commit 4b9e9cb4f6
13 changed files with 4 additions and 432 deletions
-27
View File
@@ -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"],
);
}
}
-16
View File
@@ -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,
) {
}
}
-38
View File
@@ -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));
}
}
-38
View File
@@ -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;
}
}