Documentation

ReadLimitEntityBody extends AbstractEntityBodyDecorator
in package

EntityBody decorator used to return only a subset of an entity body

Table of Contents

Properties

$body  : EntityBodyInterface
$limit  : int
$offset  : int

Methods

__call()  : mixed
Allow decorators to implement custom methods
__construct()  : mixed
__toString()  : string
Returns only a subset of the decorated entity body when cast as a string {@inheritdoc}
close()  : mixed
Close the underlying 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()  : self
Detach the current stream resource
feof()  : bool
Alias of isConsumed() {@inheritdoc}
ftell()  : int|bool
Returns the current position of the file read/write pointer
getContentEncoding()  : bool|string
Get the Content-Encoding of the EntityBody
getContentLength()  : int|bool
Returns the Content-Length of the limited subset of data {@inheritdoc}
getContentMd5()  : bool|string
Get an MD5 checksum of the stream's contents
getContentType()  : string|null
Guess the Content-Type of a local stream
getCustomData()  : null|mixed
Get custom data from the stream
getMetaData()  : array<string|int, mixed>|mixed|null
Get stream metadata
getSize()  : int|bool
Get the size of the stream if able
getStream()  : resource
Get the stream resource
getStreamType()  : string
Get a label describing the underlying implementation of the stream
getUri()  : string
Get the URI/filename associated with this stream
getWrapper()  : string
Get the stream wrapper type
getWrapperData()  : array<string|int, mixed>
Wrapper specific data attached to this stream.
isConsumed()  : bool
Check if the stream has been consumed
isLocal()  : bool
Check if the stream is a local stream vs a remote stream
isReadable()  : bool
Check if the stream is readable
isRepeatable()  : bool
Check if the stream is repeatable
isSeekable()  : bool
Check if the string is repeatable
isWritable()  : bool
Check if the stream is writable
read()  : string|bool
Read data from the stream
readLine()  : string|bool
Read a line from the stream up to the maximum allowed buffer length
rewind()  : bool
Rewind to the beginning of the stream
seek()  : bool
Allow for a bounded seek on the read limited entity body {@inheritdoc}
setCustomData()  : self
Set custom data on the stream
setLimit()  : self
Set the limit of bytes that the decorator allows to be read from the stream
setOffset()  : self
Set the offset to start limiting from
setRewindFunction()  : self
Specify a custom callback used to rewind a non-seekable stream. This can be useful entity enclosing requests that are redirected.
setSize()  : self
Specify the size of the stream in bytes
setStream()  : self
Set the stream that is wrapped by the object
uncompress()  : bool
Decompress a deflated string. Once uncompressed, the uncompressed string is then used as the wrapped stream.
write()  : int|bool
Write data to the stream

Properties

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

__construct()

public __construct(EntityBodyInterface $body, int $limit[, int $offset = 0 ]) : mixed
Parameters
$body : EntityBodyInterface

Body to wrap

$limit : int

Total number of bytes to allow to be read from the stream

$offset : int = 0

Position to seek to before reading (only works on seekable streams)

__toString()

Returns only a subset of the decorated entity body when cast as a string {@inheritdoc}

public __toString() : string
Return values
string

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

ftell()

Returns the current position of the file read/write pointer

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

Returns the position of the file pointer or false on error

getContentEncoding()

Get the Content-Encoding of the EntityBody

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

getContentLength()

Returns the Content-Length of the limited subset of data {@inheritdoc}

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()

Get custom data from the stream

public getCustomData(mixed $key) : null|mixed
Parameters
$key : mixed

Key to retrieve

Return values
null|mixed

getMetaData()

Get stream metadata

public getMetaData([mixed $key = null ]) : array<string|int, mixed>|mixed|null
Parameters
$key : mixed = null

Specific metadata to retrieve

Return values
array<string|int, mixed>|mixed|null

getStreamType()

Get a label describing the underlying implementation of the stream

public getStreamType() : string
Return values
string

getWrapperData()

Wrapper specific data attached to this stream.

public getWrapperData() : array<string|int, mixed>
Return values
array<string|int, mixed>

isConsumed()

Check if the stream has been consumed

public isConsumed() : bool
Return values
bool

read()

Read data from the stream

public read(mixed $length) : string|bool
Parameters
$length : mixed

Up to length number of bytes read.

Return values
string|bool

Returns the data read from the stream or FALSE on failure or EOF

readLine()

Read a line from the stream up to the maximum allowed buffer length

public readLine([mixed $maxLength = null ]) : string|bool
Parameters
$maxLength : mixed = null

Maximum buffer length

Return values
string|bool

rewind()

Rewind to the beginning of the stream

public rewind() : bool
Return values
bool

Returns true on success or false on failure

seek()

Allow for a bounded seek on the read limited entity body {@inheritdoc}

public seek(mixed $offset[, mixed $whence = SEEK_SET ]) : bool
Parameters
$offset : mixed

Stream offset

$whence : mixed = SEEK_SET

Where the offset is applied

Return values
bool

Returns TRUE on success or FALSE on failure

setCustomData()

Set custom data on the stream

public setCustomData(mixed $key, mixed $value) : self
Parameters
$key : mixed

Key to set

$value : mixed

Value to set

Return values
self

setLimit()

Set the limit of bytes that the decorator allows to be read from the stream

public setLimit(int $limit) : self
Parameters
$limit : int

Total number of bytes to allow to be read from the stream

Return values
self

setOffset()

Set the offset to start limiting from

public setOffset(int $offset) : self
Parameters
$offset : int

Offset to seek to and begin byte limiting from

Return values
self

setRewindFunction()

Specify a custom callback used to rewind a non-seekable stream. This can be useful entity enclosing requests that are redirected.

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.

Return values
self

setSize()

Specify the size of the stream in bytes

public setSize(mixed $size) : self
Parameters
$size : mixed

Size of the stream contents in bytes

Return values
self

setStream()

Set the stream that is wrapped by the object

public setStream(mixed $stream[, mixed $size = 0 ]) : self
Parameters
$stream : mixed

Stream resource to wrap

$size : mixed = 0

Size of the stream in bytes. Only pass if the size cannot be obtained from the stream.

Return values
self

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()

Write data to the stream

public write(mixed $string) : int|bool
Parameters
$string : mixed

The string that is to be written.

Return values
int|bool

Returns the number of bytes written to the stream on success or FALSE on failure.


        
On this page

Search results