1: <?php
2:
3: namespace Guzzle\Stream;
4:
5: /**
6: * OO interface to PHP streams
7: */
8: interface StreamInterface
9: {
10: /**
11: * Convert the stream to a string if the stream is readable and the stream is seekable.
12: *
13: * @return string
14: */
15: public function __toString();
16:
17: /**
18: * Close the underlying stream
19: */
20: public function close();
21:
22: /**
23: * Get stream metadata
24: *
25: * @param string $key Specific metadata to retrieve
26: *
27: * @return array|mixed|null
28: */
29: public function getMetaData($key = null);
30:
31: /**
32: * Get the stream resource
33: *
34: * @return resource
35: */
36: public function getStream();
37:
38: /**
39: * Set the stream that is wrapped by the object
40: *
41: * @param resource $stream Stream resource to wrap
42: * @param int $size Size of the stream in bytes. Only pass if the size cannot be obtained from the stream.
43: *
44: * @return self
45: */
46: public function setStream($stream, $size = null);
47:
48: /**
49: * Get the stream wrapper type
50: *
51: * @return string
52: */
53: public function getWrapper();
54:
55: /**
56: * Wrapper specific data attached to this stream.
57: *
58: * @return array
59: */
60: public function getWrapperData();
61:
62: /**
63: * Get a label describing the underlying implementation of the stream
64: *
65: * @return string
66: */
67: public function getStreamType();
68:
69: /**
70: * Get the URI/filename associated with this stream
71: *
72: * @return string
73: */
74: public function getUri();
75:
76: /**
77: * Get the size of the stream if able
78: *
79: * @return int|bool
80: */
81: public function getSize();
82:
83: /**
84: * Check if the stream is readable
85: *
86: * @return bool
87: */
88: public function isReadable();
89:
90: /**
91: * Check if the stream is writable
92: *
93: * @return bool
94: */
95: public function isWritable();
96:
97: /**
98: * Check if the stream has been consumed
99: *
100: * @return bool
101: */
102: public function isConsumed();
103:
104: /**
105: * Alias of isConsumed
106: *
107: * @return bool
108: */
109: public function feof();
110:
111: /**
112: * Check if the stream is a local stream vs a remote stream
113: *
114: * @return bool
115: */
116: public function isLocal();
117:
118: /**
119: * Check if the string is repeatable
120: *
121: * @return bool
122: */
123: public function isSeekable();
124:
125: /**
126: * Specify the size of the stream in bytes
127: *
128: * @param int $size Size of the stream contents in bytes
129: *
130: * @return self
131: */
132: public function setSize($size);
133:
134: /**
135: * Seek to a position in the stream
136: *
137: * @param int $offset Stream offset
138: * @param int $whence Where the offset is applied
139: *
140: * @return bool Returns TRUE on success or FALSE on failure
141: * @link http://www.php.net/manual/en/function.fseek.php
142: */
143: public function seek($offset, $whence = SEEK_SET);
144:
145: /**
146: * Read data from the stream
147: *
148: * @param int $length Up to length number of bytes read.
149: *
150: * @return string|bool Returns the data read from the stream or FALSE on failure or EOF
151: */
152: public function read($length);
153:
154: /**
155: * Write data to the stream
156: *
157: * @param string $string The string that is to be written.
158: *
159: * @return int|bool Returns the number of bytes written to the stream on success or FALSE on failure.
160: */
161: public function write($string);
162:
163: /**
164: * Returns the current position of the file read/write pointer
165: *
166: * @return int|bool Returns the position of the file pointer or false on error
167: */
168: public function ftell();
169:
170: /**
171: * Rewind to the beginning of the stream
172: *
173: * @return bool Returns true on success or false on failure
174: */
175: public function rewind();
176:
177: /**
178: * Read a line from the stream up to the maximum allowed buffer length
179: *
180: * @param int $maxLength Maximum buffer length
181: *
182: * @return string|bool
183: */
184: public function readLine($maxLength = null);
185:
186: /**
187: * Set custom data on the stream
188: *
189: * @param string $key Key to set
190: * @param mixed $value Value to set
191: *
192: * @return self
193: */
194: public function setCustomData($key, $value);
195:
196: /**
197: * Get custom data from the stream
198: *
199: * @param string $key Key to retrieve
200: *
201: * @return null|mixed
202: */
203: public function getCustomData($key);
204: }
205: