public function render()
{
$percentage = (double) ($this->value / $this->total);
$progress = floor($percentage * $this->size);
$output = "\r[" . str_repeat('=', $progress);
if ($progress < $this->size) {
$output .= ">" . str_repeat(' ', $this->size - $progress);
} else {
$output .= '=';
}
$output .= sprintf('] %s%% %s/%s', round($percentage * 100, 0), $this->value, $this->total);
if ($this->showRemainingTime) {
$speed = (time() - $this->startTime) / $this->value;
$remaining = number_format(round($speed * ($this->total - $this->value), 2), 2);
$output .= " - {$remaining} sec remaining";
}
return $output;
}