oskarstark/trimmed-non-empty-string

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

1.0.0 2022-04-11 05:08 UTC

This package is auto-updated.

Last update: 2022-06-07 05:08:52 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;
    }
}