ConsoleKit\Widgets\ProgressBar::render PHP Method

render() public method

Generates the text to write for the current values
public render ( ) : string
return string
    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;
    }