Open Journal Systems  3.3.0
GuzzleHttp\Psr7\AppendStream Class Reference
Inheritance diagram for GuzzleHttp\Psr7\AppendStream:
Psr\Http\Message\StreamInterface

Public Member Functions

 __construct (array $streams=[])
 
 __toString ()
 
 addStream (StreamInterface $stream)
 
 close ()
 
 detach ()
 
 eof ()
 
 getContents ()
 
 getMetadata ($key=null)
 
 getSize ()
 
 isReadable ()
 
 isSeekable ()
 
 isWritable ()
 
 read ($length)
 
 rewind ()
 
 seek ($offset, $whence=SEEK_SET)
 
 tell ()
 
 write ($string)
 

Detailed Description

Reads from multiple streams, one after the other.

This is a read-only stream decorator.

Definition at line 11 of file AppendStream.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 27 of file AppendStream.php.

References GuzzleHttp\Psr7\AppendStream\addStream().

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
Returns
string

Implements Psr\Http\Message\StreamInterface.

Definition at line 34 of file AppendStream.php.

References GuzzleHttp\Psr7\AppendStream\getContents(), and GuzzleHttp\Psr7\AppendStream\rewind().

◆ addStream()

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

Add a stream to the AppendStream

Parameters
StreamInterface$streamStream to append. Must be readable.
Exceptions

Definition at line 51 of file AppendStream.php.

Referenced by GuzzleHttp\Psr7\AppendStream\__construct().

◆ close()

GuzzleHttp\Psr7\AppendStream::close ( )

Closes each attached stream.

{Closes the stream and any underlying resources.

Returns
void
}

Implements Psr\Http\Message\StreamInterface.

Definition at line 75 of file AppendStream.php.

◆ detach()

GuzzleHttp\Psr7\AppendStream::detach ( )

Detaches each attached stream.

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

{Separates any underlying resources from the stream.After the stream has been detached, the stream is in an unusable state.

Returns
resource|null Underlying PHP stream, if any
}

Implements Psr\Http\Message\StreamInterface.

Definition at line 94 of file AppendStream.php.

◆ eof()

GuzzleHttp\Psr7\AppendStream::eof ( )

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

Returns
bool

Implements Psr\Http\Message\StreamInterface.

Definition at line 134 of file AppendStream.php.

Referenced by GuzzleHttp\Psr7\AppendStream\read(), and GuzzleHttp\Psr7\AppendStream\seek().

◆ getContents()

GuzzleHttp\Psr7\AppendStream::getContents ( )

Returns the remaining contents in a string

Returns
string
Exceptions

Implements Psr\Http\Message\StreamInterface.

Definition at line 65 of file AppendStream.php.

References GuzzleHttp\Psr7\copy_to_string().

Referenced by GuzzleHttp\Psr7\AppendStream\__toString().

◆ getMetadata()

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

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.

string $key Specific metadata to retrieve. array|mixed|null Returns 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.

Implements Psr\Http\Message\StreamInterface.

Definition at line 240 of file AppendStream.php.

◆ 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.

{Get the size of the stream if known.

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

Implements Psr\Http\Message\StreamInterface.

Definition at line 119 of file AppendStream.php.

◆ isReadable()

GuzzleHttp\Psr7\AppendStream::isReadable ( )

Returns whether or not the stream is readable.

Returns
bool

Implements Psr\Http\Message\StreamInterface.

Definition at line 220 of file AppendStream.php.

◆ isSeekable()

GuzzleHttp\Psr7\AppendStream::isSeekable ( )

Returns whether or not the stream is seekable.

Returns
bool

Implements Psr\Http\Message\StreamInterface.

Definition at line 230 of file AppendStream.php.

◆ isWritable()

GuzzleHttp\Psr7\AppendStream::isWritable ( )

Returns whether or not the stream is writable.

Returns
bool

Implements Psr\Http\Message\StreamInterface.

Definition at line 225 of file AppendStream.php.

◆ read()

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

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

{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.
Returns
string Returns the data read from the stream, or an empty string if no bytes are available.
Exceptions
}

Implements Psr\Http\Message\StreamInterface.

Definition at line 185 of file AppendStream.php.

References GuzzleHttp\Psr7\AppendStream\eof().

Referenced by GuzzleHttp\Psr7\AppendStream\seek().

◆ 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() on failure.

Implements Psr\Http\Message\StreamInterface.

Definition at line 141 of file AppendStream.php.

References GuzzleHttp\Psr7\AppendStream\seek().

Referenced by GuzzleHttp\Psr7\AppendStream\__toString().

◆ seek()

◆ tell()

GuzzleHttp\Psr7\AppendStream::tell ( )

Returns the current position of the file read/write pointer

Returns
int Position of the file pointer
Exceptions

Implements Psr\Http\Message\StreamInterface.

Definition at line 106 of file AppendStream.php.

◆ write()

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

Write data to the stream.

Parameters
string$stringThe string that is to be written.
Returns
int Returns the number of bytes written to the stream.
Exceptions

Implements Psr\Http\Message\StreamInterface.

Definition at line 235 of file AppendStream.php.


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