40 if ($this->stream->eof()) {
45 if ($this->limit == -1) {
49 return $this->stream->tell() >= $this->offset +
$this->limit;
58 if (null === ($length = $this->stream->getSize())) {
60 } elseif ($this->limit == -1) {
63 return min($this->limit, $length - $this->offset);
73 if ($whence !== SEEK_SET ||
$offset < 0) {
74 throw new \RuntimeException(sprintf(
75 'Cannot seek to offset % with whence %s',
83 if ($this->limit !== -1) {
84 if (
$offset > $this->offset + $this->limit) {
114 if ($this->stream->isSeekable()) {
117 throw new \RuntimeException(
"Could not seek to stream offset $offset");
140 if ($this->limit == -1) {
141 return $this->stream->read($length);
150 return $this->stream->read(min(
$remaining, $length));
eof()
Returns true if the stream is at the end of the stream.
Decorator used to return only a subset of a stream.
__construct(StreamInterface $stream, $limit=-1, $offset=0)
if($state['core:TerminatedAssocId'] !==null) $remaining
$stream
PHP stream implementation.
read($length)
Read data from the stream.
getSize()
Returns the size of the limited subset of data {Get the size of the stream if known.int|null Returns the size in bytes if known, or null if unknown.}.
tell()
Give a relative tell() {Returns the current position of the file read/write pointer.int Position of the file pointer }.
seek($offset, $whence=SEEK_SET)
Allow for a bounded seek on the read limited stream {Seek to a position in the stream.int $offset Stream offset int $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. on failure.}.
setLimit($limit)
Set the limit of bytes that the decorator allows to be read from the stream.
setOffset($offset)
Set the offset to start limiting from.