| 1 | <?php |
||
| 8 | class Buffer |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var int |
||
| 12 | */ |
||
| 13 | private $offset = 0; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var int |
||
| 17 | */ |
||
| 18 | private $length; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | private $data; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param string $data |
||
| 27 | * @param int $offset |
||
| 28 | */ |
||
| 29 | 66 | public function __construct($data = '', $offset = 0) |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Return $length bytes and move offset. |
||
| 38 | * |
||
| 39 | * @param int $length |
||
| 40 | * |
||
| 41 | * @return string |
||
| 42 | */ |
||
| 43 | 63 | public function read($length) |
|
| 50 | |||
| 51 | /** |
||
| 52 | * Return buffer total size. |
||
| 53 | * |
||
| 54 | * @return int |
||
| 55 | */ |
||
| 56 | 1 | public function size() |
|
| 60 | |||
| 61 | /** |
||
| 62 | * Check if offset reached end of the buffer. |
||
| 63 | * |
||
| 64 | * @return string |
||
| 65 | */ |
||
| 66 | 25 | public function eof() |
|
| 70 | } |
||
| 71 |