_client = $client; $this->_source = $source; $this->_destination = $destination; } /** * @param int $start * @param int $end * * @return int */ public function download(int $start, int $end):int { $this->_client->getLogController()->logDebug("[ChunkedDownload] Source: {$this->_source} Destination: {$this->_destination}"); $response = $this->_client->download($this->_source, $this->_destination, $start, $end); $headers = $response->Headers; $contentLength = isset($headers->{'content-length'}) ? (int)$headers->{'content-length'} : 0; if ($contentLength <= 0) throw new \Exception("Failed to determine content length for chunk: $start-$end"); return $contentLength; } }