| 1 | <?php | ||
| 19 | final class NameField | ||
| 20 | { | ||
| 21 | private string $name; | ||
|  | |||
| 22 | |||
| 23 | public function __construct(string $name) | ||
| 24 |     { | ||
| 25 |         if (\strlen($name) > 255) { | ||
| 26 | throw new StringExceeds255Characters(); | ||
| 27 | } | ||
| 28 | |||
| 29 | $this->name = $name; | ||
| 30 | } | ||
| 31 | |||
| 32 | public static function fromString(string $name): self | ||
| 33 |     { | ||
| 34 | return new self($name); | ||
| 35 | } | ||
| 36 | |||
| 37 | public function getValue(): string | ||
| 38 |     { | ||
| 39 | return $this->name; | ||
| 40 | } | ||
| 41 | |||
| 42 | public function slugify(): string | ||
| 43 |     { | ||
| 44 | $slugify = new Slugify(); | ||
| 45 | |||
| 46 | return $slugify->slugify($this->name); | ||
| 47 | } | ||
| 48 | } | ||
| 49 |