1 | <?php |
||
8 | class Socket implements StreamInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var resource |
||
12 | */ |
||
13 | private $stream; |
||
14 | |||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | private $tellPos = 0; |
||
19 | |||
20 | /** |
||
21 | * @var bool |
||
22 | */ |
||
23 | private $nullTerminated = false; |
||
24 | |||
25 | /** |
||
26 | * @param OptionsInterface $options |
||
27 | */ |
||
28 | 22 | public function __construct(OptionsInterface $options) |
|
36 | |||
37 | /** |
||
38 | * @param string $remote_socket |
||
39 | * @param float $timeout |
||
40 | * @param int $timeoutStream |
||
41 | */ |
||
42 | 22 | private function openStream(string $remote_socket, float $timeout, int $timeoutStream): void |
|
54 | |||
55 | /** |
||
56 | * @inheritdoc |
||
57 | */ |
||
58 | public function __toString() |
||
66 | |||
67 | /** |
||
68 | * @inheritdoc |
||
69 | */ |
||
70 | 3 | public function close() |
|
71 | { |
||
72 | 3 | fclose($this->stream); |
|
73 | 3 | $this->stream = null; |
|
74 | 3 | } |
|
75 | |||
76 | /** |
||
77 | * @inheritdoc |
||
78 | */ |
||
79 | public function detach() |
||
85 | |||
86 | /** |
||
87 | * @inheritdoc |
||
88 | */ |
||
89 | public function getSize() |
||
93 | |||
94 | /** |
||
95 | * @inheritdoc |
||
96 | */ |
||
97 | public function tell() |
||
101 | |||
102 | /** |
||
103 | * @inheritdoc |
||
104 | */ |
||
105 | 20 | public function eof() |
|
109 | |||
110 | /** |
||
111 | * @inheritdoc |
||
112 | */ |
||
113 | public function isSeekable() |
||
117 | |||
118 | /** |
||
119 | * @inheritdoc |
||
120 | */ |
||
121 | public function seek($offset, $whence = SEEK_SET) |
||
125 | |||
126 | /** |
||
127 | * @inheritdoc |
||
128 | */ |
||
129 | public function rewind() |
||
133 | |||
134 | /** |
||
135 | * Returns whether or not the stream is writable. |
||
136 | * |
||
137 | * @return bool |
||
138 | */ |
||
139 | 21 | public function isWritable() |
|
143 | |||
144 | /** |
||
145 | * Write data to the stream. |
||
146 | * |
||
147 | * @param string $string The string that is to be written. |
||
148 | * @return int Returns the number of bytes written to the stream. |
||
149 | * @throws \RuntimeException on failure. |
||
150 | */ |
||
151 | 20 | public function write($string) |
|
176 | |||
177 | /** |
||
178 | * Returns whether or not the stream is readable. |
||
179 | * |
||
180 | * @return bool |
||
181 | */ |
||
182 | public function isReadable() |
||
186 | |||
187 | /** |
||
188 | * @inheritdoc |
||
189 | */ |
||
190 | 20 | public function read($length) |
|
224 | |||
225 | /** |
||
226 | * @param $length |
||
227 | * @return string |
||
228 | * @throws Exception |
||
229 | */ |
||
230 | 20 | private function getContent($length): string |
|
245 | |||
246 | /** |
||
247 | * @inheritdoc |
||
248 | */ |
||
249 | 20 | public function getContents() |
|
260 | |||
261 | /** |
||
262 | * @inheritdoc |
||
263 | */ |
||
264 | public function getMetadata($key = null) |
||
270 | } |
||
271 |