1 | <?php |
||
26 | class Stream implements StreamInterface |
||
27 | { |
||
28 | /** @var resource Underlying socket */ |
||
29 | private $socket; |
||
30 | |||
31 | /** |
||
32 | * @var bool Is stream detached |
||
33 | */ |
||
34 | private $isDetached = false; |
||
35 | |||
36 | /** |
||
37 | * @var int|null Size of the stream, so we know what we must read, null if not available (i.e. a chunked stream) |
||
38 | */ |
||
39 | private $size; |
||
40 | |||
41 | /** |
||
42 | * @var int Size of the stream readed, to avoid reading more than available and have the user blocked |
||
43 | */ |
||
44 | private $readed = 0; |
||
45 | |||
46 | /** |
||
47 | * @var RequestInterface request associated to this stream |
||
48 | */ |
||
49 | private $request; |
||
50 | |||
51 | /** |
||
52 | * Create the stream. |
||
53 | * |
||
54 | * @param resource $socket |
||
55 | */ |
||
56 | 71 | public function __construct(RequestInterface $request, $socket, ?int $size = null) |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 51 | public function __toString() |
|
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | 5 | public function close() |
|
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | 1 | public function detach() |
|
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | 56 | public function getSize() |
|
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | 1 | public function tell() |
|
110 | |||
111 | /** |
||
112 | * {@inheritdoc} |
||
113 | */ |
||
114 | 1 | public function eof() |
|
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | 1 | public function isSeekable() |
|
126 | |||
127 | /** |
||
128 | * {@inheritdoc} |
||
129 | */ |
||
130 | 1 | public function seek($offset, $whence = SEEK_SET) |
|
134 | |||
135 | /** |
||
136 | * {@inheritdoc} |
||
137 | */ |
||
138 | 1 | public function rewind() |
|
142 | |||
143 | /** |
||
144 | * {@inheritdoc} |
||
145 | */ |
||
146 | 1 | public function isWritable() |
|
150 | |||
151 | /** |
||
152 | * {@inheritdoc} |
||
153 | */ |
||
154 | 1 | public function write($string) |
|
158 | |||
159 | /** |
||
160 | * {@inheritdoc} |
||
161 | */ |
||
162 | 1 | public function isReadable() |
|
166 | |||
167 | /** |
||
168 | * {@inheritdoc} |
||
169 | */ |
||
170 | 5 | public function read($length) |
|
191 | |||
192 | /** |
||
193 | * {@inheritdoc} |
||
194 | */ |
||
195 | 55 | public function getContents() |
|
209 | |||
210 | /** |
||
211 | * {@inheritdoc} |
||
212 | */ |
||
213 | 6 | public function getMetadata($key = null) |
|
223 | } |
||
224 |