28 lines
527 B
PHP
28 lines
527 B
PHP
<?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"],
|
|
);
|
|
}
|
|
}
|