ProgressBar
in package
The ProgressBar provides helpers to display progress output.
Tags
Table of Contents
- FORMAT_DEBUG = 'debug'
- FORMAT_NORMAL = 'normal'
- FORMAT_VERBOSE = 'verbose'
- FORMAT_VERY_VERBOSE = 'very_verbose'
- FORMAT_DEBUG_NOMAX = 'debug_nomax'
- FORMAT_NORMAL_NOMAX = 'normal_nomax'
- FORMAT_VERBOSE_NOMAX = 'verbose_nomax'
- FORMAT_VERY_VERBOSE_NOMAX = 'very_verbose_nomax'
- $barChar : mixed
- $barWidth : mixed
- $cursor : mixed
- $emptyBarChar : mixed
- $format : mixed
- $formats : mixed
- $formatters : mixed
- $internalFormat : mixed
- $lastWriteTime : mixed
- $max : mixed
- $maxSecondsBetweenRedraws : mixed
- $messages : mixed
- $minSecondsBetweenRedraws : mixed
- $output : mixed
- $overwrite : mixed
- $percent : mixed
- $previousMessage : mixed
- $progressChar : mixed
- $redrawFreq : mixed
- $startTime : mixed
- $step : mixed
- $stepWidth : mixed
- $terminal : mixed
- $writeCount : mixed
- __construct() : mixed
- advance() : mixed
- Advances the progress output X steps.
- clear() : void
- Removes the progress bar from the current line.
- display() : void
- Outputs the current progress string.
- finish() : void
- Finishes the progress output.
- getBarCharacter() : string
- getBarOffset() : float
- getBarWidth() : int
- getEmptyBarCharacter() : string
- getEstimated() : float
- getFormatDefinition() : string|null
- Gets the format for a given name.
- getMaxSteps() : int
- getMessage() : mixed
- getPlaceholderFormatterDefinition() : callable|null
- Gets the placeholder formatter for a given name.
- getProgress() : int
- getProgressCharacter() : string
- getProgressPercent() : float
- getRemaining() : float
- getStartTime() : int
- iterate() : iteratable<string|int, mixed>
- Returns an iterator that will automatically update the progress bar when iterated.
- maxSecondsBetweenRedraws() : void
- minSecondsBetweenRedraws() : void
- setBarCharacter() : mixed
- setBarWidth() : mixed
- setEmptyBarCharacter() : mixed
- setFormat() : mixed
- setFormatDefinition() : void
- Sets a format for a given name.
- setMaxSteps() : mixed
- setMessage() : mixed
- Associates a text with a named placeholder.
- setOverwrite() : mixed
- Sets whether to overwrite the progressbar, false for new line.
- setPlaceholderFormatterDefinition() : void
- Sets a placeholder formatter for a given name.
- setProgress() : mixed
- setProgressCharacter() : mixed
- setRedrawFrequency() : mixed
- Sets the redraw frequency.
- start() : mixed
- Starts the progress output.
- buildLine() : string
- determineBestFormat() : string
- getStepWidth() : int
- initFormats() : array<string|int, mixed>
- initPlaceholderFormatters() : array<string|int, mixed>
- overwrite() : void
- Overwrites a previous message to the output.
- setRealFormat() : mixed
Constants
FORMAT_DEBUG
public
mixed
FORMAT_DEBUG
= 'debug'
FORMAT_NORMAL
public
mixed
FORMAT_NORMAL
= 'normal'
FORMAT_VERBOSE
public
mixed
FORMAT_VERBOSE
= 'verbose'
FORMAT_VERY_VERBOSE
public
mixed
FORMAT_VERY_VERBOSE
= 'very_verbose'
FORMAT_DEBUG_NOMAX
private
mixed
FORMAT_DEBUG_NOMAX
= 'debug_nomax'
FORMAT_NORMAL_NOMAX
private
mixed
FORMAT_NORMAL_NOMAX
= 'normal_nomax'
FORMAT_VERBOSE_NOMAX
private
mixed
FORMAT_VERBOSE_NOMAX
= 'verbose_nomax'
FORMAT_VERY_VERBOSE_NOMAX
private
mixed
FORMAT_VERY_VERBOSE_NOMAX
= 'very_verbose_nomax'
Properties
$barChar
private
mixed
$barChar
$barWidth
private
mixed
$barWidth
= 28
$cursor
private
mixed
$cursor
$emptyBarChar
private
mixed
$emptyBarChar
= '-'
$format
private
mixed
$format
$formats
private
static mixed
$formats
$formatters
private
static mixed
$formatters
$internalFormat
private
mixed
$internalFormat
$lastWriteTime
private
mixed
$lastWriteTime
$max
private
mixed
$max
$maxSecondsBetweenRedraws
private
mixed
$maxSecondsBetweenRedraws
= 1
$messages
private
mixed
$messages
= []
$minSecondsBetweenRedraws
private
mixed
$minSecondsBetweenRedraws
= 0
$output
private
mixed
$output
$overwrite
private
mixed
$overwrite
= true
$percent
private
mixed
$percent
= 0.0
$previousMessage
private
mixed
$previousMessage
$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
$writeCount
private
mixed
$writeCount
Methods
__construct()
public
__construct(OutputInterface $output, int $max[, float $minSecondsBetweenRedraws = 1 / 25 ]) : mixed
Parameters
- $output : OutputInterface
- $max : int
-
Maximum steps (0 if unknown)
- $minSecondsBetweenRedraws : float = 1 / 25
Return values
mixed —advance()
Advances the progress output X steps.
public
advance([int $step = 1 ]) : mixed
Parameters
- $step : int = 1
-
Number of steps to advance
Return values
mixed —clear()
Removes the progress bar from the current line.
public
clear() : void
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 values
void —display()
Outputs the current progress string.
public
display() : void
Return values
void —finish()
Finishes the progress output.
public
finish() : void
Return values
void —getBarCharacter()
public
getBarCharacter() : string
Return values
string —getBarOffset()
public
getBarOffset() : float
Return values
float —getBarWidth()
public
getBarWidth() : int
Return values
int —getEmptyBarCharacter()
public
getEmptyBarCharacter() : string
Return values
string —getEstimated()
public
getEstimated() : float
Return values
float —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 —getMaxSteps()
public
getMaxSteps() : int
Return values
int —getMessage()
public
getMessage([string $name = 'message' ]) : mixed
Parameters
- $name : string = 'message'
Return values
mixed —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 —getProgress()
public
getProgress() : int
Return values
int —getProgressCharacter()
public
getProgressCharacter() : string
Return values
string —getProgressPercent()
public
getProgressPercent() : float
Return values
float —getRemaining()
public
getRemaining() : float
Return values
float —getStartTime()
public
getStartTime() : int
Return values
int —iterate()
Returns an iterator that will automatically update the progress bar when iterated.
public
iterate(iteratable<string|int, mixed> $iterable[, int|null $max = null ]) : iteratable<string|int, mixed>
Parameters
- $iterable : iteratable<string|int, mixed>
- $max : int|null = null
-
Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable
Return values
iteratable<string|int, mixed> —maxSecondsBetweenRedraws()
public
maxSecondsBetweenRedraws(float $seconds) : void
Parameters
- $seconds : float
Return values
void —minSecondsBetweenRedraws()
public
minSecondsBetweenRedraws(float $seconds) : void
Parameters
- $seconds : float
Return values
void —setBarCharacter()
public
setBarCharacter(string $char) : mixed
Parameters
- $char : string
Return values
mixed —setBarWidth()
public
setBarWidth(int $size) : mixed
Parameters
- $size : int
Return values
mixed —setEmptyBarCharacter()
public
setEmptyBarCharacter(string $char) : mixed
Parameters
- $char : string
Return values
mixed —setFormat()
public
setFormat(string $format) : mixed
Parameters
- $format : string
Return values
mixed —setFormatDefinition()
Sets a format for a given name.
public
static setFormatDefinition(string $name, string $format) : void
This method also allow you to override an existing format.
Parameters
- $name : string
-
The format name
- $format : string
-
A format string
Return values
void —setMaxSteps()
public
setMaxSteps(int $max) : mixed
Parameters
- $max : int
Return values
mixed —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
Return values
mixed —setOverwrite()
Sets whether to overwrite the progressbar, false for new line.
public
setOverwrite(bool $overwrite) : mixed
Parameters
- $overwrite : bool
Return values
mixed —setPlaceholderFormatterDefinition()
Sets a placeholder formatter for a given name.
public
static setPlaceholderFormatterDefinition(string $name, callable $callable) : void
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
Return values
void —setProgress()
public
setProgress(int $step) : mixed
Parameters
- $step : int
Return values
mixed —setProgressCharacter()
public
setProgressCharacter(string $char) : mixed
Parameters
- $char : string
Return values
mixed —setRedrawFrequency()
Sets the redraw frequency.
public
setRedrawFrequency(int|null $freq) : mixed
Parameters
- $freq : int|null
-
The frequency in steps
Return values
mixed —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
Return values
mixed —buildLine()
private
buildLine() : string
Return values
string —determineBestFormat()
private
determineBestFormat() : string
Return values
string —getStepWidth()
private
getStepWidth() : int
Return values
int —initFormats()
private
static initFormats() : array<string|int, mixed>
Return values
array<string|int, mixed> —initPlaceholderFormatters()
private
static initPlaceholderFormatters() : array<string|int, mixed>
Return values
array<string|int, mixed> —overwrite()
Overwrites a previous message to the output.
private
overwrite(string $message) : void
Parameters
- $message : string
Return values
void —setRealFormat()
private
setRealFormat(string $format) : mixed
Parameters
- $format : string