Documentation

CachingEntityBody extends AbstractEntityBodyDecorator
in package

EntityBody decorator that can cache previously read bytes from a sequentially read tstream

Table of Contents

$body  : EntityBodyInterface
$remoteStream  : EntityBody
$skipReadBytes  : int
__call()  : mixed
Allow decorators to implement custom methods
__construct()  : mixed
We will treat the buffer object as the body of the entity body {@inheritdoc}
__toString()  : string
Will give the contents of the buffer followed by the exhausted remote stream.
close()  : mixed
Close both the remote stream and buffer stream
compress()  : bool
If the stream is readable, compress the data in the stream using deflate compression. The uncompressed stream is then closed, and the compressed stream then becomes the wrapped stream.
detachStream()  : mixed
feof()  : mixed
Alias of isConsumed() {@inheritdoc}
ftell()  : mixed
getContentEncoding()  : bool|string
Get the Content-Encoding of the EntityBody
getContentLength()  : int|bool
Get the Content-Length of the entity body if possible (alias of getSize)
getContentMd5()  : bool|string
Get an MD5 checksum of the stream's contents
getContentType()  : string|null
Guess the Content-Type of a local stream
getCustomData()  : mixed
Always retrieve custom data from the remote stream {@inheritdoc}
getMetaData()  : mixed
getSize()  : mixed
getStream()  : mixed
getStreamType()  : mixed
getUri()  : mixed
getWrapper()  : mixed
getWrapperData()  : mixed
isConsumed()  : mixed
isLocal()  : mixed
isReadable()  : mixed
isRepeatable()  : mixed
isSeekable()  : mixed
isWritable()  : mixed
read()  : mixed
readLine()  : mixed
rewind()  : mixed
seek()  : mixed
setCustomData()  : mixed
Always set custom data on the remote stream {@inheritdoc}
setRewindFunction()  : self
Does not support custom rewind functions
setSize()  : mixed
setStream()  : mixed
uncompress()  : bool
Decompress a deflated string. Once uncompressed, the uncompressed string is then used as the wrapped stream.
write()  : mixed

Properties

$skipReadBytes

protected int $skipReadBytes = 0

The number of bytes to skip reading due to a write on the temporary buffer

Methods

__call()

Allow decorators to implement custom methods

public __call(string $method, array<string|int, mixed> $args) : mixed
Parameters
$method : string

Missing method name

$args : array<string|int, mixed>

Method arguments

Return values
mixed

__toString()

Will give the contents of the buffer followed by the exhausted remote stream.

public __toString() : string

Warning: Loads the entire stream into memory

Return values
string

close()

Close both the remote stream and buffer stream

public close() : mixed
Return values
mixed

compress()

If the stream is readable, compress the data in the stream using deflate compression. The uncompressed stream is then closed, and the compressed stream then becomes the wrapped stream.

public compress([mixed $filter = 'zlib.deflate' ]) : bool
Parameters
$filter : mixed = 'zlib.deflate'

Compression filter

Return values
bool

Returns TRUE on success or FALSE on failure

getContentEncoding()

Get the Content-Encoding of the EntityBody

public getContentEncoding() : bool|string
Return values
bool|string

getContentLength()

Get the Content-Length of the entity body if possible (alias of getSize)

public getContentLength() : int|bool
Return values
int|bool

Returns the Content-Length or false on failure

getContentMd5()

Get an MD5 checksum of the stream's contents

public getContentMd5([mixed $rawOutput = false ][, mixed $base64Encode = false ]) : bool|string
Parameters
$rawOutput : mixed = false

Whether or not to use raw output

$base64Encode : mixed = false

Whether or not to base64 encode raw output (only if raw output is true)

Return values
bool|string

Returns an MD5 string on success or FALSE on failure

getContentType()

Guess the Content-Type of a local stream

public getContentType() : string|null
Return values
string|null

getCustomData()

Always retrieve custom data from the remote stream {@inheritdoc}

public getCustomData(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

getMetaData()

public getMetaData([mixed $key = null ]) : mixed
Parameters
$key : mixed = null
Return values
mixed

read()

public read(mixed $length) : mixed
Parameters
$length : mixed
Return values
mixed

seek()

public seek(mixed $offset[, mixed $whence = SEEK_SET ]) : mixed
Parameters
$offset : mixed
$whence : mixed = SEEK_SET
Tags
throws
RuntimeException

When seeking with SEEK_END or when seeking past the total size of the buffer stream

Return values
mixed

setCustomData()

Always set custom data on the remote stream {@inheritdoc}

public setCustomData(mixed $key, mixed $value) : mixed
Parameters
$key : mixed
$value : mixed
Return values
mixed

setRewindFunction()

Does not support custom rewind functions

public setRewindFunction(mixed $callable) : self
Parameters
$callable : mixed

Callable to invoke to rewind a non-seekable stream. The callback must accept an EntityBodyInterface object, perform the rewind if possible, and return a boolean representing whether or not the rewind was successful.

Tags
throws
RuntimeException
Return values
self

setStream()

public setStream(mixed $stream, mixed $size) : mixed
Parameters
$stream : mixed
$size : mixed
Return values
mixed

uncompress()

Decompress a deflated string. Once uncompressed, the uncompressed string is then used as the wrapped stream.

public uncompress([mixed $filter = 'zlib.inflate' ]) : bool
Parameters
$filter : mixed = 'zlib.inflate'

De-compression filter

Return values
bool

Returns TRUE on success or FALSE on failure

write()

public write(mixed $string) : mixed
Parameters
$string : mixed
Return values
mixed

Search results