init
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user