protected function getChunkLength() { $bufferLength = strlen($this->buffer); if ($bufferLength >= $this->remainingLength) { return $this->remainingLength; } return $bufferLength; }