Class LimitStream
Decorator used to return only a subset of a stream
-
GuzzleHttp\Psr7\LimitStream
implements
Psr\Http\Message\StreamInterface
uses
GuzzleHttp\Psr7\StreamDecoratorTrait
Methods summary
public
|
#
__construct( Psr\Http\Message\StreamInterface $stream, integer $limit = -1, integer $offset = 0 )
Parameters
- $stream
- Stream to wrap
- $limit
Total number of bytes to allow to be read
from the stream. Pass -1 for no limit.
- $offset
Position to seek to before reading (only
works on seekable streams).
|
public
boolean
|
#
eof( )
Returns true if the stream is at the end of the stream.
Returns true if the stream is at the end of the stream.
Returns
boolean
Implementation of
|
public
integer|null
|
#
getSize( )
Returns the size of the limited subset of data
Get the size of the stream if known.
Returns the size of the limited subset of data
Get the size of the stream if known.
Returns
integer|null Returns the size in bytes if known, or null if unknown.
Implementation of
|
public
|
#
seek( integer $offset, integer $whence = SEEK_SET )
Allow for a bounded seek on the read limited stream
Seek to a position in the stream.
Allow for a bounded seek on the read limited stream
Seek to a position in the stream.
Parameters
- $offset
- Stream offset
- $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.
Throws
RuntimeException on failure.
Implementation of
|
public
integer
|
#
tell( )
Give a relative tell()
Returns the current position of the file read/write pointer
Give a relative tell()
Returns the current position of the file read/write pointer
Returns
integer Position of the file pointer
Throws
RuntimeException on error.
Implementation of
|
public
|
#
setOffset( integer $offset )
Set the offset to start limiting from
Set the offset to start limiting from
Parameters
- $offset
- Offset to seek to and begin byte limiting from
Throws
RuntimeException if the stream cannot be seeked.
|
public
|
#
setLimit( integer $limit )
Set the limit of bytes that the decorator allows to be read from the
stream.
Set the limit of bytes that the decorator allows to be read from the
stream.
Parameters
- $limit
Number of bytes to allow to be read from the stream.
Use -1 for no limit.
|
public
string
|
#
read( integer $length )
Read data from the stream.
Read data from the stream.
Parameters
- $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.
Throws
RuntimeException if an error occurs.
Implementation of
|
Methods used from GuzzleHttp\Psr7\StreamDecoratorTrait
__call(),
__get(),
__toString(),
close(),
createStream(),
detach(),
getContents(),
getMetadata(),
isReadable(),
isSeekable(),
isWritable(),
rewind(),
write()
|