PHP code example of oskarstark / trimmed-non-empty-string

1. Go to this page and download the library: Download oskarstark/trimmed-non-empty-string library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oskarstark / trimmed-non-empty-string example snippets




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;
    }
}