_connection = $connection; $this->_source = $source; $this->_destination = $destination; } /** * @param int $start * @param int $end * * @return int * @throws IOException */ public function download(int $start, int $end):int { return $this->_connection->retries(function() use ($start, $end) { $length = $end - $start; $fd = fopen($this->_destination, 'a'); $this->_connection->getConnection()->get($this->_source, $fd, $start, $length); return $length + 1; }, "Failed downloading chunk"); } }