class ProgressBar

Progress bar helper.

Properties

protected int $width Progressbar width.
protected string $emptyTemplate String that represents the empty part of the progess bar.
protected string $filledTemplate String that represents the filled part of the progess bar.
protected int $items Number of items.
protected float $minTimeBetweenRedraw Minimum time between redraw in seconds.
protected float $lastRedraw Time of last redraw.
protected int $progress Progress status.
protected Output $output Output instance.
protected string $prefix Progress bar prefix.

Methods

__construct(Output $output, int $items, float $minTimeBetweenRedraw = 0.1)

Constructor.

setWidth(int $width)

Sets the progress bar width.

setEmptyTemplate(string $template)

Sets the string that represents the empty part of the progess bar.

setFilledTemplate(string $template)

Sets the string that represents the filled part of the progess bar.

setPrefix(string $prefix)

Sets the progress bar prefix.

string
buildProgressBar(float $percent)

Builds the progressbar.

draw()

Draws the progressbar.

float
getMicrotime()

Return current unix timestamp with microseconds.

bool
shouldRedraw()

Should the progress bar be redrawn?

advance()

Move progress forward and redraws the progressbar.

remove()

Removes the progressbar.

Details

at line 96
__construct(Output $output, int $items, float $minTimeBetweenRedraw = 0.1)

Constructor.

Parameters

Output $output Output instance
int $items Total number of items
float $minTimeBetweenRedraw Minimum time between redraw in seconds

at line 110
setWidth(int $width)

Sets the progress bar width.

Parameters

int $width Progress bar width

at line 120
setEmptyTemplate(string $template)

Sets the string that represents the empty part of the progess bar.

Parameters

string $template Template

at line 130
setFilledTemplate(string $template)

Sets the string that represents the filled part of the progess bar.

Parameters

string $template Template

at line 140
setPrefix(string $prefix)

Sets the progress bar prefix.

Parameters

string $prefix Progress bar prefix

at line 151
protected string buildProgressBar(float $percent)

Builds the progressbar.

Parameters

float $percent Percent to fill

Return Value

string

at line 165
draw()

Draws the progressbar.

at line 199
protected float getMicrotime()

Return current unix timestamp with microseconds.

Return Value

float

at line 209
protected bool shouldRedraw()

Should the progress bar be redrawn?

Return Value

bool

at line 226
advance()

Move progress forward and redraws the progressbar.

at line 244
remove()

Removes the progressbar.