class ProgressBar

The ProgressBar provides helpers to display progress output.

Methods

__construct(OutputInterface $output, int $max)

No description

static 
setPlaceholderFormatterDefinition(string $name, callable $callable)

Sets a placeholder formatter for a given name.

static callable|null
getPlaceholderFormatterDefinition(string $name)

Gets the placeholder formatter for a given name.

static 
setFormatDefinition(string $name, string $format)

Sets a format for a given name.

static string|null
getFormatDefinition(string $name)

Gets the format for a given name.

setMessage(string $message, string $name = 'message')

Associates a text with a named placeholder.

getMessage($name = 'message')

No description

int
getStartTime()

Gets the progress bar start time.

int
getMaxSteps()

Gets the progress bar maximal steps.

int
getProgress()

Gets the current step position.

float
getProgressPercent()

Gets the current progress bar percent.

setBarWidth(int $size)

Sets the progress bar width.

int
getBarWidth()

Gets the progress bar width.

setBarCharacter(string $char)

Sets the bar character.

string
getBarCharacter()

Gets the bar character.

setEmptyBarCharacter(string $char)

Sets the empty bar character.

string
getEmptyBarCharacter()

Gets the empty bar character.

setProgressCharacter(string $char)

Sets the progress bar character.

string
getProgressCharacter()

Gets the progress bar character.

setFormat(string $format)

Sets the progress bar format.

setRedrawFrequency(int|float $freq)

Sets the redraw frequency.

start(int|null $max = null)

Starts the progress output.

advance(int $step = 1)

Advances the progress output X steps.

setOverwrite(bool $overwrite)

Sets whether to overwrite the progressbar, false for new line.

setProgress(int $step)

Sets the current progress.

finish()

Finishes the progress output.

display()

Outputs the current progress string.

clear()

Removes the progress bar from the current line.

Details

at line line 58
__construct(OutputInterface $output, int $max)

Parameters

OutputInterface $output An OutputInterface instance
int $max Maximum steps (0 if unknown)

at line line 87
static setPlaceholderFormatterDefinition(string $name, callable $callable)

Sets a placeholder formatter for a given name.

This method also allow you to override an existing placeholder.

Parameters

string $name The placeholder name (including the delimiter char like %)
callable $callable A PHP callable

at line line 103
static callable|null getPlaceholderFormatterDefinition(string $name)

Gets the placeholder formatter for a given name.

Parameters

string $name The placeholder name (including the delimiter char like %)

Return Value

callable|null A PHP callable

at line line 120
static setFormatDefinition(string $name, string $format)

Sets a format for a given name.

This method also allow you to override an existing format.

Parameters

string $name The format name
string $format A format string

at line line 136
static string|null getFormatDefinition(string $name)

Gets the format for a given name.

Parameters

string $name The format name

Return Value

string|null A format string

at line line 155
setMessage(string $message, string $name = 'message')

Associates a text with a named placeholder.

The text is displayed when the progress bar is rendered but only when the corresponding placeholder is part of the custom format line (by wrapping the name with %).

Parameters

string $message The text to associate with the placeholder
string $name The name of the placeholder

at line line 160
getMessage($name = 'message')

Parameters

$name

at line line 170
int getStartTime()

Gets the progress bar start time.

Return Value

int The progress bar start time

at line line 180
int getMaxSteps()

Gets the progress bar maximal steps.

Return Value

int The progress bar max steps

at line line 190
int getProgress()

Gets the current step position.

Return Value

int The progress bar step

at line line 210
float getProgressPercent()

Gets the current progress bar percent.

Return Value

float The current progress bar percent

at line line 220
setBarWidth(int $size)

Sets the progress bar width.

Parameters

int $size The progress bar size

at line line 230
int getBarWidth()

Gets the progress bar width.

Return Value

int The progress bar size

at line line 240
setBarCharacter(string $char)

Sets the bar character.

Parameters

string $char A character

at line line 250
string getBarCharacter()

Gets the bar character.

Return Value

string A character

at line line 264
setEmptyBarCharacter(string $char)

Sets the empty bar character.

Parameters

string $char A character

at line line 274
string getEmptyBarCharacter()

Gets the empty bar character.

Return Value

string A character

at line line 284
setProgressCharacter(string $char)

Sets the progress bar character.

Parameters

string $char A character

at line line 294
string getProgressCharacter()

Gets the progress bar character.

Return Value

string A character

at line line 304
setFormat(string $format)

Sets the progress bar format.

Parameters

string $format The format

at line line 315
setRedrawFrequency(int|float $freq)

Sets the redraw frequency.

Parameters

int|float $freq The frequency in steps

at line line 325
start(int|null $max = null)

Starts the progress output.

Parameters

int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged

at line line 343
advance(int $step = 1)

Advances the progress output X steps.

Parameters

int $step Number of steps to advance

at line line 353
setOverwrite(bool $overwrite)

Sets whether to overwrite the progressbar, false for new line.

Parameters

bool $overwrite

at line line 363
setProgress(int $step)

Sets the current progress.

Parameters

int $step The current progress

at line line 385
finish()

Finishes the progress output.

at line line 402
display()

Outputs the current progress string.

at line line 422
clear()

Removes the progress bar from the current line.

This is useful if you wish to write some output while a progress bar is running. Call display() to show the progress bar again.