Example #1
0
 /**
  * The progress function
  *
  * @author Art <*****@*****.**>
  *
  * @param resource $resource     Coulsn't find documentation on this one, most likely the curl resource
  * @param int      $downloadSize How much we are downloading
  * @param int      $downloaded   How much we have downloaded
  * @param int      $uploadSize   How much we are uploading
  * @param int      $uploaded     How much we have uploaded
  */
 function progressFunction($resource, $downloadSize, $downloaded, $uploadSize, $uploaded)
 {
     $ed = $size = 0;
     if ($downloadSize > 0 && $downloaded > 0) {
         $ed = $downloaded;
         $size = $downloadSize;
     } elseif ($uploadSize > 0 && $uploaded > 0) {
         $ed = $uploaded;
         $size = $uploadSize;
     }
     if ($ed && $size && $this->reportCount++ != 0) {
         $status = File::convertSize($ed) . '/' . File::convertSize($size) . ' downloaded [' . round($ed / $size * 100, 3) . ' %]';
         $time = time();
         if ($status != $this->lastReportStatus && ($time != $this->lastReportTime || $ed == $size)) {
             $this->lastReportTime = $time;
             $this->lastReportStatus = $status;
             echo $status . PHP_EOL;
         }
         $this->reportCount++;
     }
     //Unnecessary, but stops the IDE from thinking the variable is unused
     unset($resource);
 }