Protobuf\Stream::fromString PHP Method

fromString() public static method

Create a new stream from a string.
public static fromString ( string $resource = '', integer $size = null ) : Stream
$resource string
$size integer
return Stream
    public static function fromString($resource = '', $size = null)
    {
        $stream = fopen('php://temp', 'r+');
        if ($resource !== '') {
            fwrite($stream, $resource);
            fseek($stream, 0);
        }
        return new self($stream, $size);
    }