ProgressBar
in package
The ProgressBar provides helpers to display progress output.
Tags
Table of Contents
Properties
- $barChar : mixed
- $barWidth : mixed
- $emptyBarChar : mixed
- $firstRun : mixed
- $format : mixed
- $formatLineCount : mixed
- $formats : mixed
- $formatters : mixed
- $internalFormat : mixed
- $max : mixed
- $messages : mixed
- $output : OutputInterface
- $overwrite : mixed
- $percent : mixed
- $progressChar : mixed
- $redrawFreq : mixed
- $startTime : mixed
- $step : mixed
- $stepWidth : mixed
- $terminal : mixed
Methods
- __construct() : mixed
- advance() : mixed
- Advances the progress output X steps.
- clear() : mixed
- Removes the progress bar from the current line.
- display() : mixed
- Outputs the current progress string.
- finish() : mixed
- Finishes the progress output.
- getBarCharacter() : string
- Gets the bar character.
- getBarWidth() : int
- Gets the progress bar width.
- getEmptyBarCharacter() : string
- Gets the empty bar character.
- getFormatDefinition() : string|null
- Gets the format for a given name.
- getMaxSteps() : int
- Gets the progress bar maximal steps.
- getMessage() : mixed
- getPlaceholderFormatterDefinition() : callable|null
- Gets the placeholder formatter for a given name.
- getProgress() : int
- Gets the current step position.
- getProgressCharacter() : string
- Gets the progress bar character.
- getProgressPercent() : float
- Gets the current progress bar percent.
- getStartTime() : int
- Gets the progress bar start time.
- setBarCharacter() : mixed
- Sets the bar character.
- setBarWidth() : mixed
- Sets the progress bar width.
- setEmptyBarCharacter() : mixed
- Sets the empty bar character.
- setFormat() : mixed
- Sets the progress bar format.
- setFormatDefinition() : mixed
- Sets a format for a given name.
- setMessage() : mixed
- Associates a text with a named placeholder.
- setOverwrite() : mixed
- Sets whether to overwrite the progressbar, false for new line.
- setPlaceholderFormatterDefinition() : mixed
- Sets a placeholder formatter for a given name.
- setProgress() : mixed
- Sets the current progress.
- setProgressCharacter() : mixed
- Sets the progress bar character.
- setRedrawFrequency() : mixed
- Sets the redraw frequency.
- start() : mixed
- Starts the progress output.
- buildLine() : string
- determineBestFormat() : mixed
- getStepWidth() : int
- Gets the progress bar step width.
- initFormats() : mixed
- initPlaceholderFormatters() : mixed
- overwrite() : mixed
- Overwrites a previous message to the output.
- setMaxSteps() : mixed
- Sets the progress bar maximal steps.
- setRealFormat() : mixed
- Sets the progress bar format.
Properties
$barChar
private
mixed
$barChar
$barWidth
private
mixed
$barWidth
= 28
$emptyBarChar
private
mixed
$emptyBarChar
= '-'
$firstRun
private
mixed
$firstRun
= true
$format
private
mixed
$format
$formatLineCount
private
mixed
$formatLineCount
$formats
private
static mixed
$formats
$formatters
private
static mixed
$formatters
$internalFormat
private
mixed
$internalFormat
$max
private
mixed
$max
$messages
private
mixed
$messages
= array()
$output
private
OutputInterface
$output
$overwrite
private
mixed
$overwrite
= true
$percent
private
mixed
$percent
= 0.0
$progressChar
private
mixed
$progressChar
= '>'
$redrawFreq
private
mixed
$redrawFreq
= 1
$startTime
private
mixed
$startTime
$step
private
mixed
$step
= 0
$stepWidth
private
mixed
$stepWidth
$terminal
private
mixed
$terminal
Methods
__construct()
public
__construct(OutputInterface $output[, int $max = 0 ]) : mixed
Parameters
- $output : OutputInterface
-
An OutputInterface instance
- $max : int = 0
-
Maximum steps (0 if unknown)
advance()
Advances the progress output X steps.
public
advance([int $step = 1 ]) : mixed
Parameters
- $step : int = 1
-
Number of steps to advance
clear()
Removes the progress bar from the current line.
public
clear() : mixed
This is useful if you wish to write some output while a progress bar is running. Call display() to show the progress bar again.
display()
Outputs the current progress string.
public
display() : mixed
finish()
Finishes the progress output.
public
finish() : mixed
getBarCharacter()
Gets the bar character.
public
getBarCharacter() : string
Return values
string —A character
getBarWidth()
Gets the progress bar width.
public
getBarWidth() : int
Return values
int —The progress bar size
getEmptyBarCharacter()
Gets the empty bar character.
public
getEmptyBarCharacter() : string
Return values
string —A character
getFormatDefinition()
Gets the format for a given name.
public
static getFormatDefinition(string $name) : string|null
Parameters
- $name : string
-
The format name
Return values
string|null —A format string
getMaxSteps()
Gets the progress bar maximal steps.
public
getMaxSteps() : int
Return values
int —The progress bar max steps
getMessage()
public
getMessage([mixed $name = 'message' ]) : mixed
Parameters
- $name : mixed = 'message'
getPlaceholderFormatterDefinition()
Gets the placeholder formatter for a given name.
public
static getPlaceholderFormatterDefinition(string $name) : callable|null
Parameters
- $name : string
-
The placeholder name (including the delimiter char like %)
Return values
callable|null —A PHP callable
getProgress()
Gets the current step position.
public
getProgress() : int
Return values
int —The progress bar step
getProgressCharacter()
Gets the progress bar character.
public
getProgressCharacter() : string
Return values
string —A character
getProgressPercent()
Gets the current progress bar percent.
public
getProgressPercent() : float
Return values
float —The current progress bar percent
getStartTime()
Gets the progress bar start time.
public
getStartTime() : int
Return values
int —The progress bar start time
setBarCharacter()
Sets the bar character.
public
setBarCharacter(string $char) : mixed
Parameters
- $char : string
-
A character
setBarWidth()
Sets the progress bar width.
public
setBarWidth(int $size) : mixed
Parameters
- $size : int
-
The progress bar size
setEmptyBarCharacter()
Sets the empty bar character.
public
setEmptyBarCharacter(string $char) : mixed
Parameters
- $char : string
-
A character
setFormat()
Sets the progress bar format.
public
setFormat(string $format) : mixed
Parameters
- $format : string
-
The format
setFormatDefinition()
Sets a format for a given name.
public
static setFormatDefinition(string $name, string $format) : mixed
This method also allow you to override an existing format.
Parameters
- $name : string
-
The format name
- $format : string
-
A format string
setMessage()
Associates a text with a named placeholder.
public
setMessage(string $message[, string $name = 'message' ]) : mixed
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
- $message : string
-
The text to associate with the placeholder
- $name : string = 'message'
-
The name of the placeholder
setOverwrite()
Sets whether to overwrite the progressbar, false for new line.
public
setOverwrite(bool $overwrite) : mixed
Parameters
- $overwrite : bool
setPlaceholderFormatterDefinition()
Sets a placeholder formatter for a given name.
public
static setPlaceholderFormatterDefinition(string $name, callable $callable) : mixed
This method also allow you to override an existing placeholder.
Parameters
- $name : string
-
The placeholder name (including the delimiter char like %)
- $callable : callable
-
A PHP callable
setProgress()
Sets the current progress.
public
setProgress(int $step) : mixed
Parameters
- $step : int
-
The current progress
setProgressCharacter()
Sets the progress bar character.
public
setProgressCharacter(string $char) : mixed
Parameters
- $char : string
-
A character
setRedrawFrequency()
Sets the redraw frequency.
public
setRedrawFrequency(int|float $freq) : mixed
Parameters
- $freq : int|float
-
The frequency in steps
start()
Starts the progress output.
public
start([int|null $max = null ]) : mixed
Parameters
- $max : int|null = null
-
Number of steps to complete the bar (0 if indeterminate), null to leave unchanged
buildLine()
private
buildLine() : string
Return values
stringdetermineBestFormat()
private
determineBestFormat() : mixed
getStepWidth()
Gets the progress bar step width.
private
getStepWidth() : int
Return values
int —The progress bar step width
initFormats()
private
static initFormats() : mixed
initPlaceholderFormatters()
private
static initPlaceholderFormatters() : mixed
overwrite()
Overwrites a previous message to the output.
private
overwrite(string $message) : mixed
Parameters
- $message : string
-
The message
setMaxSteps()
Sets the progress bar maximal steps.
private
setMaxSteps(int $max) : mixed
Parameters
- $max : int
-
The progress bar max steps
setRealFormat()
Sets the progress bar format.
private
setRealFormat(string $format) : mixed
Parameters
- $format : string
-
The format