Trait that implements the Stringable interface. Allows string conversion of class to string output.

Trait synopsis

trait StringableTrait
{
    use TypeTrait;

    // Stringable interface implementation.

    /**
     * Return string representation.
     * @return string String representation.
     */
    public function __toString(): string;
}

Examples


use Phrity\O\String\StringableTrait;

class MyClass implements Stringable
{
    use StringableTrait;

    public function __construct(string $input)
    {
        $this->initialize($input);
    }
}

$class = new MyClass("hey");
echo $class; // => "hey"