| Conditions | 3 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 33 | public function readAll(string $path): string |
||
| 34 | { |
||
| 35 | $buffer = $this->ffi->new("unsigned char[4096]"); |
||
| 36 | |||
| 37 | $fd = $this->ffi->open($path, 0); |
||
| 38 | $result = ""; |
||
| 39 | $done = false; |
||
| 40 | do { |
||
| 41 | $read_len = $this->ffi->read($fd, $buffer, 4096); |
||
| 42 | if ($read_len > 0) { |
||
| 43 | $result .= FFI::string($buffer, min($read_len, 4096)); |
||
| 44 | } else { |
||
| 45 | $done = true; |
||
| 46 | } |
||
| 47 | } while (!$done); |
||
| 48 | $this->ffi->close($fd); |
||
| 49 | |||
| 50 | return $result; |
||
| 51 | } |
||
| 53 |