Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Created February 7, 2021 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szepeviktor/6003fb6e2a35c0e5f9eb29c96623e4b7 to your computer and use it in GitHub Desktop.
Save szepeviktor/6003fb6e2a35c0e5f9eb29c96623e4b7 to your computer and use it in GitHub Desktop.
Empty String Generator v1.0.0
<?php
namespace DoNot\Ever\DoThis;
final class EmptyStringGenerator
{
protected const EMPTY_STRING = '';
protected string $string;
public function __construct()
{
$this->string = self::EMPTY_STRING;
}
public function get(): self
{
return $this;
}
public function __toString(): string
{
return $this->string;
}
}
@szepeviktor
Copy link
Author

Usage

$generator = new EmptyStringGenerator();

var_dump('Hello World!' . $generator->get()); // string(12) "Hello World!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment