* @returns string bytes read from buffer * @todo test for fencepost errors wrt updating current_index */
($len)
| 122 | * @todo test for fencepost errors wrt updating current_index |
| 123 | */ |
| 124 | public function read($len) |
| 125 | { |
| 126 | $this->checkClosed(); |
| 127 | $read = ''; |
| 128 | for ($i = $this->current_index; $i < ($this->current_index + $len); $i++) { |
| 129 | $read .= $this->string_buffer[$i] ?? ''; |
| 130 | } |
| 131 | if (strlen($read) < $len) { |
| 132 | $this->current_index = $this->length(); |
| 133 | } else { |
| 134 | $this->current_index += $len; |
| 135 | } |
| 136 | return $read; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * @returns int count of bytes in the buffer |
nothing calls this directly
no test coverage detected