\GuzzleHttp\Psr7CachingStream

Stream decorator that can cache previously read bytes from a sequentially read stream.

Summary

Methods
Properties
Constants
__construct()
__get()
__toString()
getContents()
__call()
close()
getMetadata()
detach()
getSize()
eof()
tell()
isReadable()
isWritable()
isSeekable()
rewind()
seek()
read()
write()
No public properties found
No constants found
createStream()
No protected properties found
N/A
cacheEntireStream()
$remoteStream
$skipReadBytes
N/A

Properties

$skipReadBytes

$skipReadBytes : integer

Type

integer — Number of bytes to skip reading due to a write on the buffer

Methods

__get()

__get(string  $name) : \Psr\Http\Message\StreamInterface

Magic method used to create a new stream if streams are not added in the constructor of a decorator (e.g., LazyOpenStream).

Parameters

string $name

Name of the property (allows "stream" only).

Returns

\Psr\Http\Message\StreamInterface

__toString()

__toString() 

getContents()

getContents() 

__call()

__call(string  $method, array  $args) : mixed

Allow decorators to implement custom methods

Parameters

string $method

Missing method name

array $args

Method arguments

Returns

mixed

close()

close() : void

Close both the remote stream and buffer stream

getMetadata()

getMetadata(  $key = null) 

Parameters

$key

detach()

detach() 

getSize()

getSize() : integer|null

Get the size of the stream if known.

Returns

integer|null —

Returns the size in bytes if known, or null if unknown.

eof()

eof() : boolean

Returns true if the stream is at the end of the stream.

Returns

boolean

tell()

tell() 

isReadable()

isReadable() 

isWritable()

isWritable() 

isSeekable()

isSeekable() 

rewind()

rewind() 

Seek to the beginning of the stream.

If the stream is not seekable, this method will raise an exception; otherwise, it will perform a seek(0).

seek()

seek(integer  $offset, integer  $whence = SEEK_SET) 

Seek to a position in the stream.

Parameters

integer $offset

Stream offset

integer $whence

Specifies how the cursor position will be calculated based on the seek offset. Valid values are identical to the built-in PHP $whence values for fseek(). SEEK_SET: Set position equal to offset bytes SEEK_CUR: Set position to current location plus offset SEEK_END: Set position to end-of-stream plus offset.

read()

read(integer  $length) : string

Read data from the stream.

Parameters

integer $length

Read up to $length bytes from the object and return them. Fewer than $length bytes may be returned if underlying stream call returns fewer bytes.

Returns

string —

Returns the data read from the stream, or an empty string if no bytes are available.

write()

write(string  $string) : integer

Write data to the stream.

Parameters

string $string

The string that is to be written.

Returns

integer —

Returns the number of bytes written to the stream.

createStream()

createStream() : \Psr\Http\Message\StreamInterface

Implement in subclasses to dynamically create streams when requested.

Throws

\BadMethodCallException

Returns

\Psr\Http\Message\StreamInterface

cacheEntireStream()

cacheEntireStream()