1 | <?php |
||
25 | class Stream implements StreamInterface |
||
26 | { |
||
27 | /** @var resource Underlying socket */ |
||
28 | private $socket; |
||
29 | |||
30 | /** |
||
31 | * @var bool Is stream detached |
||
32 | */ |
||
33 | private $isDetached = false; |
||
34 | |||
35 | /** |
||
36 | * @var int|null Size of the stream, so we know what we must read, null if not available (i.e. a chunked stream) |
||
37 | */ |
||
38 | private $size; |
||
39 | |||
40 | /** |
||
41 | * @var int Size of the stream readed, to avoid reading more than available and have the user blocked |
||
42 | */ |
||
43 | private $readed = 0; |
||
44 | |||
45 | /** |
||
46 | * Create the stream |
||
47 | * |
||
48 | * @param resource $socket |
||
49 | * @param integer $size |
||
50 | */ |
||
51 | 70 | public function __construct($socket, $size = null) |
|
56 | |||
57 | /** |
||
58 | * {@inheritDoc} |
||
59 | */ |
||
60 | 1 | public function __toString() |
|
64 | |||
65 | /** |
||
66 | * {@inheritDoc} |
||
67 | */ |
||
68 | 4 | public function close() |
|
72 | |||
73 | /** |
||
74 | * {@inheritDoc} |
||
75 | */ |
||
76 | 1 | public function detach() |
|
84 | |||
85 | /** |
||
86 | * {@inheritDoc} |
||
87 | */ |
||
88 | 57 | public function getSize() |
|
92 | |||
93 | /** |
||
94 | * {@inheritDoc} |
||
95 | */ |
||
96 | 1 | public function tell() |
|
100 | |||
101 | /** |
||
102 | * {@inheritDoc} |
||
103 | */ |
||
104 | 1 | public function eof() |
|
108 | |||
109 | /** |
||
110 | * {@inheritDoc} |
||
111 | */ |
||
112 | 1 | public function isSeekable() |
|
116 | |||
117 | /** |
||
118 | * {@inheritDoc} |
||
119 | */ |
||
120 | 1 | public function seek($offset, $whence = SEEK_SET) |
|
124 | |||
125 | /** |
||
126 | * {@inheritDoc} |
||
127 | */ |
||
128 | 1 | public function rewind() |
|
132 | |||
133 | /** |
||
134 | * {@inheritDoc} |
||
135 | */ |
||
136 | 1 | public function isWritable() |
|
140 | |||
141 | /** |
||
142 | * {@inheritDoc} |
||
143 | */ |
||
144 | 1 | public function write($string) |
|
148 | |||
149 | /** |
||
150 | * {@inheritDoc} |
||
151 | */ |
||
152 | 1 | public function isReadable() |
|
156 | |||
157 | /** |
||
158 | * {@inheritDoc} |
||
159 | */ |
||
160 | 3 | public function read($length) |
|
185 | |||
186 | /** |
||
187 | * {@inheritDoc} |
||
188 | */ |
||
189 | 57 | public function getContents() |
|
203 | |||
204 | /** |
||
205 | * {@inheritDoc} |
||
206 | */ |
||
207 | 4 | public function getMetadata($key = null) |
|
217 | } |
||
218 |