\GuzzleHttp\Psr7LimitStream

Decorator used to return only a subset of a stream

Summary

Methods
Properties
Constants
__construct()
__get()
__toString()
getContents()
__call()
close()
getMetadata()
detach()
getSize()
eof()
tell()
isReadable()
isWritable()
isSeekable()
rewind()
seek()
read()
write()
setOffset()
setLimit()
No public properties found
No constants found
createStream()
No protected properties found
N/A
No private methods found
$offset
$limit
N/A

Properties

$offset

$offset : integer

Type

integer — Offset to start reading from

$limit

$limit : integer

Type

integer — Limit the number of bytes that can be read

Methods

__construct()

__construct(\Psr\Http\Message\StreamInterface  $stream, integer  $limit = -1, integer  $offset) 

Parameters

\Psr\Http\Message\StreamInterface $stream

Stream to wrap

integer $limit

Total number of bytes to allow to be read from the stream. Pass -1 for no limit.

integer $offset

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

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

getMetadata()

getMetadata(  $key = null) 

Parameters

$key

detach()

detach() 

getSize()

getSize() : integer|null

Returns the size of the limited subset of data {@inheritdoc}

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

Give a relative tell() {@inheritdoc}

Returns

integer —

Position of the file pointer

isReadable()

isReadable() 

isWritable()

isWritable() 

isSeekable()

isSeekable() 

rewind()

rewind() 

seek()

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

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

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) 

Parameters

$string

setOffset()

setOffset(integer  $offset) 

Set the offset to start limiting from

Parameters

integer $offset

Offset to seek to and begin byte limiting from

Throws

\RuntimeException

if the stream cannot be seeked.

setLimit()

setLimit(integer  $limit) 

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

Parameters

integer $limit

Number of bytes to allow to be read from the stream. Use -1 for no limit.

createStream()

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

Implement in subclasses to dynamically create streams when requested.

Throws

\BadMethodCallException

Returns

\Psr\Http\Message\StreamInterface