class ProgressBar

The ProgressBar provides helpers to display progress output.

Methods

__construct(OutputInterface $output, int $max = 0)

No description

static void
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 void
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(string $name = 'message')

No description

int
getStartTime()

No description

int
getMaxSteps()

No description

int
getProgress()

No description

float
getProgressPercent()

No description

setBarWidth(int $size)

No description

int
getBarWidth()

No description

setBarCharacter(string $char)

No description

string
getBarCharacter()

No description

setEmptyBarCharacter(string $char)

No description

string
getEmptyBarCharacter()

No description

setProgressCharacter(string $char)

No description

string
getProgressCharacter()

No description

setFormat(string $format)

No description

setRedrawFrequency(int $freq)

Sets the redraw frequency.

start(int $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)

No description

setMaxSteps(int $max)

No description

void
finish()

Finishes the progress output.

void
display()

Outputs the current progress string.

void
clear()

Removes the progress bar from the current line.

Details

at line 54
__construct(OutputInterface $output, int $max = 0)

Parameters

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

at line 83
static void 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

Return Value

void

at line 99
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 116
static void 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

Return Value

void

at line 132
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 151
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 156
getMessage(string $name = 'message')

Parameters

string $name

at line 161
int getStartTime()

Return Value

int

at line 166
int getMaxSteps()

Return Value

int

at line 171
int getProgress()

Return Value

int

at line 181
float getProgressPercent()

Return Value

float

at line 186
setBarWidth(int $size)

Parameters

int $size

at line 191
int getBarWidth()

Return Value

int

at line 196
setBarCharacter(string $char)

Parameters

string $char

at line 201
string getBarCharacter()

Return Value

string

at line 210
setEmptyBarCharacter(string $char)

Parameters

string $char

at line 215
string getEmptyBarCharacter()

Return Value

string

at line 220
setProgressCharacter(string $char)

Parameters

string $char

at line 225
string getProgressCharacter()

Return Value

string

at line 230
setFormat(string $format)

Parameters

string $format

at line 241
setRedrawFrequency(int $freq)

Sets the redraw frequency.

Parameters

int $freq The frequency in steps

at line 251
start(int $max = null)

Starts the progress output.

Parameters

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

at line 269
advance(int $step = 1)

Advances the progress output X steps.

Parameters

int $step Number of steps to advance

at line 277
setOverwrite(bool $overwrite)

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

Parameters

bool $overwrite

at line 282
setProgress(int $step)

Parameters

int $step

at line 299
setMaxSteps(int $max)

Parameters

int $max

at line 309
void finish()

Finishes the progress output.

Return Value

void

at line 326
void display()

Outputs the current progress string.

Return Value

void

at line 346
void 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.

Return Value

void