Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
GuzzleHttp\Psr7\LimitStream Class Reference
Inheritance diagram for GuzzleHttp\Psr7\LimitStream:
Psr\Http\Message\StreamInterface

Public Member Functions

 __construct (StreamInterface $stream, int $limit=-1, int $offset=0)
 
 __toString ()
 Reads all data from the stream into a string, from the beginning to end.
 
 close ()
 Closes the stream and any underlying resources.
 
 detach ()
 Separates any underlying resources from the stream.
 
 eof ()
 Returns true if the stream is at the end of the stream.
 
 getContents ()
 Returns the remaining contents in a string.
 
 getMetadata ($key=null)
 Get stream metadata as an associative array or retrieve a specific key.
 
 getSize ()
 Returns the size of the limited subset of data.
 
 isReadable ()
 Returns whether or not the stream is readable.
 
 isSeekable ()
 Returns whether or not the stream is seekable.
 
 isWritable ()
 Returns whether or not the stream is writable.
 
 read ($length)
 Read data from the stream.
 
 rewind ()
 Seek to the beginning of the stream.
 
 seek ($offset, $whence=SEEK_SET)
 Allow for a bounded seek on the read limited stream.
 
 setLimit (int $limit)
 Set the limit of bytes that the decorator allows to be read from the stream.
 
 setOffset (int $offset)
 Set the offset to start limiting from.
 
 tell ()
 Give a relative tell()
 
 write ($string)
 Write data to the stream.
 

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Psr7\LimitStream::__construct ( StreamInterface $stream,
int $limit = -1,
int $offset = 0 )
Parameters
StreamInterface$streamStream to wrap
int$limitTotal number of bytes to allow to be read from the stream. Pass -1 for no limit.
int$offsetPosition to seek to before reading (only works on seekable streams).

Member Function Documentation

◆ __toString()

Psr\Http\Message\StreamInterface::__toString ( )
inherited

Reads all data from the stream into a string, from the beginning to end.

This method MUST attempt to seek to the beginning of the stream before reading data and read the stream until the end is reached.

Warning: This could attempt to load a large amount of data into memory.

This method MUST NOT raise an exception in order to conform with PHP's string casting operations.

See also
http://php.net/manual/en/language.oop5.magic.php#object.tostring
Return values
string

Implemented in GuzzleHttp\Psr7\AppendStream, GuzzleHttp\Psr7\BufferStream, GuzzleHttp\Psr7\FnStream, GuzzleHttp\Psr7\PumpStream, GuzzleHttp\Psr7\Stream, and ZipStream\Stream.

◆ close()

Psr\Http\Message\StreamInterface::close ( )
inherited

◆ detach()

Psr\Http\Message\StreamInterface::detach ( )
inherited

Separates any underlying resources from the stream.

After the stream has been detached, the stream is in an unusable state.

Return values
resource|nullUnderlying PHP stream, if any

Implemented in GuzzleHttp\Psr7\AppendStream, GuzzleHttp\Psr7\BufferStream, GuzzleHttp\Psr7\FnStream, GuzzleHttp\Psr7\PumpStream, GuzzleHttp\Psr7\Stream, and ZipStream\Stream.

◆ eof()

GuzzleHttp\Psr7\LimitStream::eof ( )

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

Return values
bool

Implements Psr\Http\Message\StreamInterface.

◆ getContents()

Psr\Http\Message\StreamInterface::getContents ( )
inherited

Returns the remaining contents in a string.

Return values
string
Exceptions
RuntimeExceptionif unable to read or an error occurs while reading.

Implemented in GuzzleHttp\Psr7\AppendStream, GuzzleHttp\Psr7\BufferStream, GuzzleHttp\Psr7\FnStream, GuzzleHttp\Psr7\PumpStream, GuzzleHttp\Psr7\Stream, and ZipStream\Stream.

◆ getMetadata()

Psr\Http\Message\StreamInterface::getMetadata ( $key = null)
inherited

Get stream metadata as an associative array or retrieve a specific key.

The keys returned are identical to the keys returned from PHP's stream_get_meta_data() function.

@externalurl http://php.net/manual/en/function.stream-get-meta-data.php

Parameters
string$keySpecific metadata to retrieve.
Return values
array|mixed|nullReturns an associative array if no key is provided. Returns a specific key value if a key is provided and the value is found, or null if the key is not found.

Implemented in GuzzleHttp\Psr7\AppendStream, GuzzleHttp\Psr7\BufferStream, GuzzleHttp\Psr7\FnStream, GuzzleHttp\Psr7\PumpStream, GuzzleHttp\Psr7\Stream, and ZipStream\Stream.

◆ getSize()

GuzzleHttp\Psr7\LimitStream::getSize ( )

Returns the size of the limited subset of data.

Implements Psr\Http\Message\StreamInterface.

◆ isReadable()

Psr\Http\Message\StreamInterface::isReadable ( )
inherited

Returns whether or not the stream is readable.

Return values
bool

Implemented in GuzzleHttp\Psr7\AppendStream, GuzzleHttp\Psr7\BufferStream, GuzzleHttp\Psr7\FnStream, GuzzleHttp\Psr7\PumpStream, GuzzleHttp\Psr7\Stream, and ZipStream\Stream.

◆ isSeekable()

Psr\Http\Message\StreamInterface::isSeekable ( )
inherited

◆ isWritable()

Psr\Http\Message\StreamInterface::isWritable ( )
inherited

◆ read()

GuzzleHttp\Psr7\LimitStream::read ( $length)

Read data from the stream.

Parameters
int$lengthRead up to $length bytes from the object and return them. Fewer than $length bytes may be returned if underlying stream call returns fewer bytes.
Return values
stringReturns the data read from the stream, or an empty string if no bytes are available.
Exceptions
RuntimeExceptionif an error occurs.

Implements Psr\Http\Message\StreamInterface.

◆ rewind()

Psr\Http\Message\StreamInterface::rewind ( )
inherited

Seek to the beginning of the stream.

If the stream is not seekable, this method will raise an exception; otherwise, it will perform a seek(0).

See also
seek() @externalurl http://www.php.net/manual/en/function.fseek.php
Exceptions
RuntimeExceptionon failure.

Implemented in GuzzleHttp\Psr7\AppendStream, GuzzleHttp\Psr7\BufferStream, GuzzleHttp\Psr7\CachingStream, GuzzleHttp\Psr7\FnStream, GuzzleHttp\Psr7\PumpStream, GuzzleHttp\Psr7\Stream, and ZipStream\Stream.

◆ seek()

GuzzleHttp\Psr7\LimitStream::seek ( $offset,
$whence = SEEK_SET )

Allow for a bounded seek on the read limited stream.

Implements Psr\Http\Message\StreamInterface.

◆ setLimit()

GuzzleHttp\Psr7\LimitStream::setLimit ( int $limit)

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

Parameters
int$limitNumber of bytes to allow to be read from the stream. Use -1 for no limit.

◆ setOffset()

GuzzleHttp\Psr7\LimitStream::setOffset ( int $offset)

Set the offset to start limiting from.

Parameters
int$offsetOffset to seek to and begin byte limiting from
Exceptions
RuntimeExceptionif the stream cannot be seeked.

◆ tell()

GuzzleHttp\Psr7\LimitStream::tell ( )

Give a relative tell()

Implements Psr\Http\Message\StreamInterface.

◆ write()

Psr\Http\Message\StreamInterface::write ( $string)
inherited

Write data to the stream.

Parameters
string$stringThe string that is to be written.
Return values
intReturns the number of bytes written to the stream.
Exceptions
RuntimeExceptionon failure.

Implemented in GuzzleHttp\Psr7\AppendStream, GuzzleHttp\Psr7\BufferStream, GuzzleHttp\Psr7\CachingStream, GuzzleHttp\Psr7\DroppingStream, GuzzleHttp\Psr7\FnStream, GuzzleHttp\Psr7\PumpStream, GuzzleHttp\Psr7\Stream, and ZipStream\Stream.


The documentation for this class was generated from the following file: