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

Public Member Functions

 __construct ($hwm=16384)
 
 __toString ()
 
 close ()
 
 detach ()
 
 eof ()
 
 getContents ()
 
 getMetadata ($key=null)
 
 getSize ()
 
 isReadable ()
 
 isSeekable ()
 
 isWritable ()
 
 read ($length)
 
 rewind ()
 
 seek ($offset, $whence=SEEK_SET)
 
 tell ()
 
 write ($string)
 

Detailed Description

Provides a buffer stream that can be written to to fill a buffer, and read from to remove bytes from the buffer.

This stream returns a "hwm" metadata value that tells upstream consumers what the configured high water mark of the stream is, or the maximum preferred size of the buffer.

Definition at line 14 of file BufferStream.php.

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Psr7\BufferStream::__construct (   $hwm = 16384)
Parameters
int$hwmHigh water mark, representing the preferred maximum buffer size. If the size of the buffer exceeds the high water mark, then calls to write will continue to succeed but will return false to inform writers to slow down until the buffer has been drained by reading from it.

Definition at line 26 of file BufferStream.php.

Member Function Documentation

◆ __toString()

GuzzleHttp\Psr7\BufferStream::__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 31 of file BufferStream.php.

References GuzzleHttp\Psr7\BufferStream\getContents().

◆ close()

GuzzleHttp\Psr7\BufferStream::close ( )

Closes the stream and any underlying resources.

Returns
void

Implements Psr\Http\Message\StreamInterface.

Definition at line 44 of file BufferStream.php.

Referenced by GuzzleHttp\Psr7\BufferStream\detach().

◆ detach()

GuzzleHttp\Psr7\BufferStream::detach ( )

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 49 of file BufferStream.php.

References GuzzleHttp\Psr7\BufferStream\close().

◆ eof()

GuzzleHttp\Psr7\BufferStream::eof ( )

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

Returns
bool

Implements Psr\Http\Message\StreamInterface.

Definition at line 84 of file BufferStream.php.

◆ getContents()

GuzzleHttp\Psr7\BufferStream::getContents ( )

Returns the remaining contents in a string

Returns
string
Exceptions

Implements Psr\Http\Message\StreamInterface.

Definition at line 36 of file BufferStream.php.

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

◆ getMetadata()

GuzzleHttp\Psr7\BufferStream::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 129 of file BufferStream.php.

◆ getSize()

GuzzleHttp\Psr7\BufferStream::getSize ( )

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 54 of file BufferStream.php.

◆ isReadable()

GuzzleHttp\Psr7\BufferStream::isReadable ( )

Returns whether or not the stream is readable.

Returns
bool

Implements Psr\Http\Message\StreamInterface.

Definition at line 59 of file BufferStream.php.

◆ isSeekable()

GuzzleHttp\Psr7\BufferStream::isSeekable ( )

Returns whether or not the stream is seekable.

Returns
bool

Implements Psr\Http\Message\StreamInterface.

Definition at line 69 of file BufferStream.php.

◆ isWritable()

GuzzleHttp\Psr7\BufferStream::isWritable ( )

Returns whether or not the stream is writable.

Returns
bool

Implements Psr\Http\Message\StreamInterface.

Definition at line 64 of file BufferStream.php.

◆ read()

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

Reads data from the buffer.

Implements Psr\Http\Message\StreamInterface.

Definition at line 97 of file BufferStream.php.

◆ rewind()

GuzzleHttp\Psr7\BufferStream::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 74 of file BufferStream.php.

References GuzzleHttp\Psr7\BufferStream\seek().

◆ seek()

◆ tell()

GuzzleHttp\Psr7\BufferStream::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 89 of file BufferStream.php.

◆ write()

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

Writes data to the buffer.

Implements Psr\Http\Message\StreamInterface.

Definition at line 117 of file BufferStream.php.


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