ProgressBar
in package
The ProgressBar provides helpers to display progress output.
Tags
Table of Contents
Properties
- $barChar : mixed
- $barWidth : mixed
- $emptyBarChar : mixed
- $format : mixed
- $formatLineCount : 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
Methods
- __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() : int
- getBarWidth() : int
- getEmptyBarCharacter() : string
- 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
- getStartTime() : int
- iterate() : iterable<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
Properties
$barChar
private
mixed
$barChar
$barWidth
private
mixed
$barWidth
= 28
$emptyBarChar
private
mixed
$emptyBarChar
= '-'
$format
private
mixed
$format
$formatLineCount
private
mixed
$formatLineCount
$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 = 0 ][, float $minSecondsBetweenRedraws = 0.1 ]) : mixed
Parameters
- $output : OutputInterface
- $max : int = 0
-
Maximum steps (0 if unknown)
- $minSecondsBetweenRedraws : float = 0.1
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() : 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.
display()
Outputs the current progress string.
public
display() : void
finish()
Finishes the progress output.
public
finish() : void
getBarCharacter()
public
getBarCharacter() : string
Return values
stringgetBarOffset()
public
getBarOffset() : int
Return values
intgetBarWidth()
public
getBarWidth() : int
Return values
intgetEmptyBarCharacter()
public
getEmptyBarCharacter() : string
Return values
stringgetFormatDefinition()
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()
public
getMaxSteps() : int
Return values
intgetMessage()
public
getMessage([string $name = 'message' ]) : mixed
Parameters
- $name : string = '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()
public
getProgress() : int
Return values
intgetProgressCharacter()
public
getProgressCharacter() : string
Return values
stringgetProgressPercent()
public
getProgressPercent() : float
Return values
floatgetStartTime()
public
getStartTime() : int
Return values
intiterate()
Returns an iterator that will automatically update the progress bar when iterated.
public
iterate(iterable<string|int, mixed> $iterable[, int|null $max = null ]) : iterable<string|int, mixed>
Parameters
- $iterable : iterable<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
iterable<string|int, mixed>maxSecondsBetweenRedraws()
public
maxSecondsBetweenRedraws(float $seconds) : void
Parameters
- $seconds : float
minSecondsBetweenRedraws()
public
minSecondsBetweenRedraws(float $seconds) : void
Parameters
- $seconds : float
setBarCharacter()
public
setBarCharacter(string $char) : mixed
Parameters
- $char : string
setBarWidth()
public
setBarWidth(int $size) : mixed
Parameters
- $size : int
setEmptyBarCharacter()
public
setEmptyBarCharacter(string $char) : mixed
Parameters
- $char : string
setFormat()
public
setFormat(string $format) : mixed
Parameters
- $format : string
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
setMaxSteps()
public
setMaxSteps(int $max) : mixed
Parameters
- $max : int
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) : 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
setProgress()
public
setProgress(int $step) : mixed
Parameters
- $step : int
setProgressCharacter()
public
setProgressCharacter(string $char) : mixed
Parameters
- $char : string
setRedrawFrequency()
Sets the redraw frequency.
public
setRedrawFrequency(int|null $freq) : mixed
Parameters
- $freq : int|null
-
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() : string
Return values
stringgetStepWidth()
private
getStepWidth() : int
Return values
intinitFormats()
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
setRealFormat()
private
setRealFormat(string $format) : mixed
Parameters
- $format : string