_source = fopen($source, 'r'); $this->_destination = fopen($destination, 'a'); } /** * @return string */ public function download(int $start, int $end):int { fseek($this->_source, $start); $readed = 0; $left = $end - $start; while($left && !feof($this->_source)) { $read = fread($this->_source, min($left, 1024 * 1024)); fwrite($this->_destination, $read); $left -= strlen($read); $readed += strlen($read); } return $readed; } }