\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 : int

Type

int — Offset to start reading from

$limit

$limit : int

Type

int — Limit the number of bytes that can be read

Methods

__construct()

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

Parameters

\Psr\Http\Message\StreamInterface $stream

Stream to wrap

int $limit

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

int $offset

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

Returns

mixed —

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

Returns

mixed —

getContents()

getContents() : mixed

Returns

mixed —

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

Returns

mixed —

getMetadata()

getMetadata(mixed  $key = null) : mixed

Parameters

mixed $key

Returns

mixed —

detach()

detach() : mixed

Returns

mixed —

getSize()

getSize() : int|null

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

Returns

int|null —

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

eof()

eof() : bool

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

Returns

bool —

tell()

tell() : int

Give a relative tell() {@inheritdoc}

Returns

int —

Position of the file pointer

isReadable()

isReadable() : mixed

Returns

mixed —

isWritable()

isWritable() : mixed

Returns

mixed —

isSeekable()

isSeekable() : mixed

Returns

mixed —

rewind()

rewind() : mixed

Returns

mixed —

seek()

seek(mixed  $offset, mixed  $whence = SEEK_SET) : mixed

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

Parameters

mixed $offset

Stream offset

mixed $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.

Returns

mixed —

read()

read(mixed  $length) : string

Read data from the stream.

Parameters

mixed $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(mixed  $string) : mixed

Parameters

mixed $string

Returns

mixed —

setOffset()

setOffset(int  $offset) : mixed

Set the offset to start limiting from

Parameters

int $offset

Offset to seek to and begin byte limiting from

Throws

\RuntimeException

if the stream cannot be seeked.

Returns

mixed —

setLimit()

setLimit(int  $limit) : mixed

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

Parameters

int $limit

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

Returns

mixed —

createStream()

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

Implement in subclasses to dynamically create streams when requested.

Throws

\BadMethodCallException

Returns

\Psr\Http\Message\StreamInterface —