MemoryStream implements DestinationStream, SourceStream
Interfaces
Methods
- __construct() : mixed
- __destruct() : mixed
- append() : DestinationStream
- close() : void
- We are not closing memory streams, in order to cleanup memory use rm on Memory Filesystem.
- content() : string
- fromResource() : DestinationStream
- isOpen() : bool
- iterate() : Generator<string|int, string>
- path() : Path
- read() : string
- readLines() : Generator<string|int, string>
- size() : null|int
Methods
__construct()
    public
                    __construct(resource $handle, Path $path) : mixed
    Parameters
- $handle : resource
- $path : Path
__destruct()
    public
                    __destruct() : mixed
    append()
    public
                    append(string $data) : DestinationStream
    Parameters
- $data : string
Return values
DestinationStreamclose()
We are not closing memory streams, in order to cleanup memory use rm on Memory Filesystem.
    public
                    close() : void
    content()
    public
                    content() : string
    Return values
stringfromResource()
    public
                    fromResource(mixed $resource) : DestinationStream
    Parameters
- $resource : mixed
Return values
DestinationStreamisOpen()
    public
                    isOpen() : bool
    Return values
booliterate()
    public
                    iterate([int $length = 1 ]) : Generator<string|int, string>
    Parameters
- $length : int = 1
- 
                    number of bytes to read from the stream 
Return values
Generator<string|int, string>path()
    public
                    path() : Path
    Return values
Pathread()
    public
                    read(int $length, int $offset) : string
    Parameters
- $length : int
- 
                    number of bytes to read from the stream 
- $offset : int
- 
                    The offset where to start reading from the stream. If negative, reading will start from the end of the stream. 
Return values
stringreadLines()
    public
                    readLines([string $separator = "
" ][, int|null $length = null ]) : Generator<string|int, string>
    Parameters
- $separator : string = " "
- 
                    The line separator, content will be read until the first occurrence of the separator 
- $length : int|null = null
- 
                    Number of bytes to read in one step. If the end of the stream or separator is reached before the specified number of bytes are read, the remaining bytes are returned. Otherwise we are reading until the separator is found or end of file is reached. When working with remote streams it might be a good idea to set length to few mb in orders to reduce number of network requests. When no value is provided, filesystems will use a default value, for example NativeLocalFilesystem is going to use 8192 length. 
Return values
Generator<string|int, string>size()
    public
                    size() : null|int
    Return values
null|int —The size of the stream in bytes