Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 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
     * Detach the current stream resource
50
     *
51
     * @return self
52
     */
53
    public function detachStream();
54
 
55
    /**
56
     * Get the stream wrapper type
57
     *
58
     * @return string
59
     */
60
    public function getWrapper();
61
 
62
    /**
63
     * Wrapper specific data attached to this stream.
64
     *
65
     * @return array
66
     */
67
    public function getWrapperData();
68
 
69
    /**
70
     * Get a label describing the underlying implementation of the stream
71
     *
72
     * @return string
73
     */
74
    public function getStreamType();
75
 
76
    /**
77
     * Get the URI/filename associated with this stream
78
     *
79
     * @return string
80
     */
81
    public function getUri();
82
 
83
    /**
84
     * Get the size of the stream if able
85
     *
86
     * @return int|bool
87
     */
88
    public function getSize();
89
 
90
    /**
91
     * Check if the stream is readable
92
     *
93
     * @return bool
94
     */
95
    public function isReadable();
96
 
97
    /**
98
     * Check if the stream is repeatable
99
     *
100
     * @return bool
101
     */
102
    public function isRepeatable();
103
 
104
    /**
105
     * Check if the stream is writable
106
     *
107
     * @return bool
108
     */
109
    public function isWritable();
110
 
111
    /**
112
     * Check if the stream has been consumed
113
     *
114
     * @return bool
115
     */
116
    public function isConsumed();
117
 
118
    /**
119
     * Alias of isConsumed
120
     *
121
     * @return bool
122
     */
123
    public function feof();
124
 
125
    /**
126
     * Check if the stream is a local stream vs a remote stream
127
     *
128
     * @return bool
129
     */
130
    public function isLocal();
131
 
132
    /**
133
     * Check if the string is repeatable
134
     *
135
     * @return bool
136
     */
137
    public function isSeekable();
138
 
139
    /**
140
     * Specify the size of the stream in bytes
141
     *
142
     * @param int $size Size of the stream contents in bytes
143
     *
144
     * @return self
145
     */
146
    public function setSize($size);
147
 
148
    /**
149
     * Seek to a position in the stream
150
     *
151
     * @param int $offset Stream offset
152
     * @param int $whence Where the offset is applied
153
     *
154
     * @return bool Returns TRUE on success or FALSE on failure
155
     * @link   http://www.php.net/manual/en/function.fseek.php
156
     */
157
    public function seek($offset, $whence = SEEK_SET);
158
 
159
    /**
160
     * Read data from the stream
161
     *
162
     * @param int $length Up to length number of bytes read.
163
     *
164
     * @return string|bool Returns the data read from the stream or FALSE on failure or EOF
165
     */
166
    public function read($length);
167
 
168
    /**
169
     * Write data to the stream
170
     *
171
     * @param string $string The string that is to be written.
172
     *
173
     * @return int|bool Returns the number of bytes written to the stream on success or FALSE on failure.
174
     */
175
    public function write($string);
176
 
177
    /**
178
     * Returns the current position of the file read/write pointer
179
     *
180
     * @return int|bool Returns the position of the file pointer or false on error
181
     */
182
    public function ftell();
183
 
184
    /**
185
     * Rewind to the beginning of the stream
186
     *
187
     * @return bool Returns true on success or false on failure
188
     */
189
    public function rewind();
190
 
191
    /**
192
     * Read a line from the stream up to the maximum allowed buffer length
193
     *
194
     * @param int $maxLength Maximum buffer length
195
     *
196
     * @return string|bool
197
     */
198
    public function readLine($maxLength = null);
199
 
200
    /**
201
     * Set custom data on the stream
202
     *
203
     * @param string $key   Key to set
204
     * @param mixed  $value Value to set
205
     *
206
     * @return self
207
     */
208
    public function setCustomData($key, $value);
209
 
210
    /**
211
     * Get custom data from the stream
212
     *
213
     * @param string $key Key to retrieve
214
     *
215
     * @return null|mixed
216
     */
217
    public function getCustomData($key);
218
}