1 | <?php |
||
9 | class Socket implements StreamInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var resource |
||
13 | */ |
||
14 | private $stream; |
||
15 | |||
16 | /** |
||
17 | * @var int |
||
18 | */ |
||
19 | private $tellPos = 0; |
||
20 | |||
21 | /** |
||
22 | * @var bool |
||
23 | */ |
||
24 | private $nullTerminated = false; |
||
25 | |||
26 | /** |
||
27 | * @param OptionsInterface $options |
||
28 | */ |
||
29 | 14 | public function __construct(OptionsInterface $options) |
|
37 | |||
38 | /** |
||
39 | * @param string $remote_socket |
||
40 | * @param float $timeout |
||
41 | * @param int $timeoutStream |
||
42 | */ |
||
43 | 14 | private function openStream(string $remote_socket, float $timeout, int $timeoutStream): void |
|
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | public function __toString() |
||
67 | |||
68 | /** |
||
69 | * @inheritdoc |
||
70 | */ |
||
71 | public function close() |
||
72 | { |
||
73 | fclose($this->stream); |
||
74 | $this->stream = null; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @inheritdoc |
||
79 | */ |
||
80 | public function detach() |
||
86 | |||
87 | /** |
||
88 | * @inheritdoc |
||
89 | */ |
||
90 | public function getSize() |
||
94 | |||
95 | /** |
||
96 | * @inheritdoc |
||
97 | */ |
||
98 | public function tell() |
||
102 | |||
103 | /** |
||
104 | * @inheritdoc |
||
105 | */ |
||
106 | 14 | public function eof() |
|
110 | |||
111 | /** |
||
112 | * @inheritdoc |
||
113 | */ |
||
114 | public function isSeekable() |
||
118 | |||
119 | /** |
||
120 | * @inheritdoc |
||
121 | */ |
||
122 | public function seek($offset, $whence = SEEK_SET) |
||
126 | |||
127 | /** |
||
128 | * @inheritdoc |
||
129 | */ |
||
130 | public function rewind() |
||
134 | |||
135 | /** |
||
136 | * Returns whether or not the stream is writable. |
||
137 | * |
||
138 | * @return bool |
||
139 | */ |
||
140 | 14 | public function isWritable() |
|
144 | |||
145 | /** |
||
146 | * Write data to the stream. |
||
147 | * |
||
148 | * @param string $string The string that is to be written. |
||
149 | * @return int Returns the number of bytes written to the stream. |
||
150 | * @throws \RuntimeException on failure. |
||
151 | */ |
||
152 | 14 | public function write($string) |
|
181 | |||
182 | /** |
||
183 | * Returns whether or not the stream is readable. |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | public function isReadable() |
||
191 | |||
192 | /** |
||
193 | * @inheritdoc |
||
194 | */ |
||
195 | 14 | public function read($length) |
|
229 | |||
230 | /** |
||
231 | * @param $length |
||
232 | * @return string |
||
233 | * @throws Exception |
||
234 | */ |
||
235 | 14 | private function getContent($length): string |
|
250 | |||
251 | /** |
||
252 | * @inheritdoc |
||
253 | */ |
||
254 | 14 | public function getContents() |
|
265 | |||
266 | /** |
||
267 | * @inheritdoc |
||
268 | */ |
||
269 | public function getMetadata($key = null) |
||
275 | } |
||
276 |