12 use StreamDecoratorTrait;
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));
An exception for terminatinating execution or to throw for unit testing.
Decorator used to return only a subset of a stream.
tell()
Give a relative tell() {Returns the current position of the file read/write pointer....
setOffset($offset)
Set the offset to start limiting from.
eof()
Returns true if the stream is at the end of the stream.
seek($offset, $whence=SEEK_SET)
Allow for a bounded seek on the read limited stream {Seek to a position in the stream....
read($length)
Read data from the stream.
setLimit($limit)
Set the limit of bytes that the decorator allows to be read from the stream.
getSize()
Returns the size of the limited subset of data {Get the size of the stream if known....
__construct(StreamInterface $stream, $limit=-1, $offset=0)
$stream
PHP stream implementation.
if($state['core:TerminatedAssocId'] !==null) $remaining