Conditions | 5 |
Paths | 4 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | public function read(int $numBytes, callable $callback) : void |
||
35 | { |
||
36 | $meta = stream_get_meta_data($this->stream); |
||
37 | if ($meta['blocked'] && ($meta['unread_bytes'] > 0)) { |
||
38 | stream_set_blocking($this->stream, false); |
||
39 | } |
||
40 | $buffer = fread($this->stream, $numBytes); |
||
41 | if ($meta['blocked'] && ($meta['unread_bytes'] > 0)) { |
||
42 | stream_set_blocking($this->stream, true); |
||
43 | } |
||
44 | |||
45 | $callback($buffer); |
||
46 | } |
||
56 |