2
namespace GuzzleHttp\Stream;
5
* Describes a stream instance.
7
interface StreamInterface
10
* Attempts to seek to the beginning of the stream and reads all data into
11
* a string until the end of the stream is reached.
13
* Warning: This could attempt to load a large amount of data into memory.
17
public function __toString();
20
* Closes the stream and any underlying resources.
22
public function close();
25
* Separates any underlying resources from the stream.
27
* After the underlying resource has been detached, the stream object is in
28
* an unusable state. If you wish to use a Stream object as a PHP stream
29
* but keep the Stream object in a consistent state, use
30
* {@see GuzzleHttp\Stream\GuzzleStreamWrapper::getResource}.
32
* @return resource|null Returns the underlying PHP stream resource or null
33
* if the Stream object did not utilize an underlying
36
public function detach();
39
* Get the size of the stream if known
41
* @return int|null Returns the size in bytes if known, or null if unknown
43
public function getSize();
46
* Returns the current position of the file read/write pointer
48
* @return int|bool Returns the position of the file pointer or false on error
50
public function tell();
53
* Returns true if the stream is at the end of the stream.
57
public function eof();
60
* Returns whether or not the stream is seekable
64
public function isSeekable();
67
* Seek to a position in the stream
69
* @param int $offset Stream offset
70
* @param int $whence Specifies how the cursor position will be calculated
71
* based on the seek offset. Valid values are identical
72
* to the built-in PHP $whence values for `fseek()`.
73
* SEEK_SET: Set position equal to offset bytes
74
* SEEK_CUR: Set position to current location plus offset
75
* SEEK_END: Set position to end-of-stream plus offset
77
* @return bool Returns true on success or false on failure
78
* @link http://www.php.net/manual/en/function.fseek.php
80
public function seek($offset, $whence = SEEK_SET);
83
* Returns whether or not the stream is writable
87
public function isWritable();
90
* Write data to the stream
92
* @param string $string The string that is to be written.
94
* @return int|bool Returns the number of bytes written to the stream on
95
* success or false on failure.
97
public function write($string);
100
* Flush the write buffers of the stream.
102
* @return bool Returns true on success and false on failure
104
public function flush();
107
* Returns whether or not the stream is readable
111
public function isReadable();
114
* Read data from the stream
116
* @param int $length Read up to $length bytes from the object and return
117
* them. Fewer than $length bytes may be returned if
118
* underlying stream call returns fewer bytes.
120
* @return string Returns the data read from the stream.
122
public function read($length);
125
* Returns the remaining contents in a string, up to maxlength bytes.
127
* @param int $maxLength The maximum bytes to read. Defaults to -1 (read
128
* all the remaining buffer).
131
public function getContents($maxLength = -1);