Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
GuzzleHttp\Psr7\AppendStream Class Reference
Inheritance diagram for GuzzleHttp\Psr7\AppendStream:
Psr\Http\Message\StreamInterface

Public Member Functions

 __construct (array $streams=[])
 
 __toString ()
 Reads all data from the stream into a string, from the beginning to end.
 
 addStream (StreamInterface $stream)
 Add a stream to the AppendStream.
 
 close ()
 Closes each attached stream.
 
 detach ()
 Detaches each attached 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)
 
 getSize ()
 Tries to calculate the size by adding the size of each stream.
 
 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)
 Reads from all of the appended streams until the length is met or EOF.
 
 rewind ()
 Seek to the beginning of the stream.
 
 seek ($offset, $whence=SEEK_SET)
 Attempts to seek to the given position.
 
 tell ()
 Returns the current position of the file read/write pointer.
 
 write ($string)
 Write data to the stream.
 

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Psr7\AppendStream::__construct ( array $streams = [])
Parameters
StreamInterface[]$streamsStreams to decorate. Each stream must be readable.

Member Function Documentation

◆ __toString()

GuzzleHttp\Psr7\AppendStream::__toString ( )

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

Implements Psr\Http\Message\StreamInterface.

◆ addStream()

GuzzleHttp\Psr7\AppendStream::addStream ( StreamInterface $stream)

Add a stream to the AppendStream.

Parameters
StreamInterface$streamStream to append. Must be readable.
Exceptions
InvalidArgumentExceptionif the stream is not readable

◆ close()

GuzzleHttp\Psr7\AppendStream::close ( )

Closes each attached stream.

Implements Psr\Http\Message\StreamInterface.

◆ detach()

GuzzleHttp\Psr7\AppendStream::detach ( )

Detaches each attached stream.

Returns null as it's not clear which underlying stream resource to return.

Implements Psr\Http\Message\StreamInterface.

◆ eof()

GuzzleHttp\Psr7\AppendStream::eof ( )

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

Return values
bool

Implements Psr\Http\Message\StreamInterface.

◆ getContents()

GuzzleHttp\Psr7\AppendStream::getContents ( )

Returns the remaining contents in a string.

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

Implements Psr\Http\Message\StreamInterface.

◆ getMetadata()

GuzzleHttp\Psr7\AppendStream::getMetadata ( $key = null)
Return values
mixed

Implements Psr\Http\Message\StreamInterface.

◆ getSize()

GuzzleHttp\Psr7\AppendStream::getSize ( )

Tries to calculate the size by adding the size of each stream.

If any of the streams do not return a valid number, then the size of the append stream cannot be determined and null is returned.

Implements Psr\Http\Message\StreamInterface.

◆ isReadable()

GuzzleHttp\Psr7\AppendStream::isReadable ( )

Returns whether or not the stream is readable.

Return values
bool

Implements Psr\Http\Message\StreamInterface.

◆ isSeekable()

GuzzleHttp\Psr7\AppendStream::isSeekable ( )

Returns whether or not the stream is seekable.

Return values
bool

Implements Psr\Http\Message\StreamInterface.

◆ isWritable()

GuzzleHttp\Psr7\AppendStream::isWritable ( )

Returns whether or not the stream is writable.

Return values
bool

Implements Psr\Http\Message\StreamInterface.

◆ read()

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

Reads from all of the appended streams until the length is met or EOF.

Implements Psr\Http\Message\StreamInterface.

◆ rewind()

GuzzleHttp\Psr7\AppendStream::rewind ( )

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.

Implements Psr\Http\Message\StreamInterface.

◆ seek()

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

Attempts to seek to the given position.

Only supports SEEK_SET.

Implements Psr\Http\Message\StreamInterface.

◆ tell()

GuzzleHttp\Psr7\AppendStream::tell ( )

Returns the current position of the file read/write pointer.

Return values
intPosition of the file pointer
Exceptions
RuntimeExceptionon error.

Implements Psr\Http\Message\StreamInterface.

◆ write()

GuzzleHttp\Psr7\AppendStream::write ( $string)

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.

Implements Psr\Http\Message\StreamInterface.


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