oskarstark/trimmed-non-empty-string

This library provides a value object which ensures a trimmed non empty string.

1.2.0 2024-08-01 09:13 UTC

This package is auto-updated.

Last update: 2024-11-11 11:59:22 UTC


README

This library provides a value object which ensures a trimmed non empty string.

CI

Installation

composer require oskarstark/trimmed-non-empty-string

Usage

<?php

declare(strict_types=1);

namespace App\Domain\Value\Name;

use OskarStark\Value\TrimmedNonEmptyString;

final class Name
{
    private string $value;

    private function __construct(string $value)
    {
        $this->value = TrimmedNonEmptyString::fromString($value)->toString();
    }

    public static function fromString(string $value): self
    {
        return new self($value);
    }

    public function toString(): string
    {
        return $this->value;
    }
}