43 lines
747 B
PHP
43 lines
747 B
PHP
<?php
|
|
|
|
namespace Lucent\Field;
|
|
|
|
use JsonSerializable;
|
|
use Lucent\LucentException;
|
|
use Lucent\Validator\Validator;
|
|
|
|
|
|
class FieldName implements JsonSerializable
|
|
{
|
|
public string $value;
|
|
|
|
/**
|
|
* @throws LucentException
|
|
*/
|
|
function __construct(string $value)
|
|
{
|
|
Validator::single("Name", $value, "min:2|max:50|alpha_dash");
|
|
$this->value = $value;
|
|
}
|
|
|
|
public function value(): string
|
|
{
|
|
return $this->value;
|
|
}
|
|
|
|
public function equals(FieldName $name): bool
|
|
{
|
|
return $this->value === $name->value;
|
|
}
|
|
|
|
public function __toString(): string
|
|
{
|
|
return $this->value;
|
|
}
|
|
|
|
public function jsonSerialize(): string
|
|
{
|
|
return $this->value;
|
|
}
|
|
}
|