ProgressBar
in package
Console progress bar class
Tags
Table of Contents
Properties
- $barChar : string
- Character used for the filled portion of the bar
- $bg : int|null
- Background color of the filled portion
- $current : int
- Current step
- $emptyChar : string
- Character used for the unfilled portion of the bar
- $fg : int|null
- Foreground color of the filled portion
- $finished : bool
- Flag for if the progress bar has finished
- $indent : string
- Indent prefix
- $lastLine : string|null
- Last rendered line, so redraws are skipped when the visible output hasn't changed
- $message : string|null
- Optional leading message
- $progressChar : string
- Character used at the leading edge of the filled portion
- $total : int
- Total number of steps
- $width : int
- Width of the bar's fill portion
Methods
- __construct() : mixed
- Instantiate the progress bar object
- advance() : ProgressBar
- Advance the progress bar by the given number of steps
- finish() : ProgressBar
- Finish the progress bar
- getCurrent() : int
- Get the current progress
- getTotal() : int
- Get the total number of steps
- isFinished() : bool
- Determine if the progress bar has finished
- setChars() : ProgressBar
- Set the bar characters
- setColor() : ProgressBar
- Set the color of the filled portion of the bar
- setIndent() : ProgressBar
- Set the indent prefix
- setMessage() : ProgressBar
- Set the leading message
- setProgress() : ProgressBar
- Set the current progress
- setWidth() : ProgressBar
- Set the width of the bar's fill portion
- buildLine() : string
- Build the progress bar line
- render() : void
- Render the progress bar to the console
Properties
$barChar
Character used for the filled portion of the bar
protected
string
$barChar
= '='
$bg
Background color of the filled portion
protected
int|null
$bg
= null
$current
Current step
protected
int
$current
= 0
$emptyChar
Character used for the unfilled portion of the bar
protected
string
$emptyChar
= ' '
$fg
Foreground color of the filled portion
protected
int|null
$fg
= null
$finished
Flag for if the progress bar has finished
protected
bool
$finished
= false
$indent
Indent prefix
protected
string
$indent
= ''
$lastLine
Last rendered line, so redraws are skipped when the visible output hasn't changed
protected
string|null
$lastLine
= null
$message
Optional leading message
protected
string|null
$message
= null
$progressChar
Character used at the leading edge of the filled portion
protected
string
$progressChar
= '>'
$total
Total number of steps
protected
int
$total
$width
Width of the bar's fill portion
protected
int
$width
= 28
Methods
__construct()
Instantiate the progress bar object
public
__construct(int $total[, string|null $message = null ][, int $width = 28 ]) : mixed
Parameters
- $total : int
- $message : string|null = null
- $width : int = 28
Tags
advance()
Advance the progress bar by the given number of steps
public
advance([int $step = 1 ]) : ProgressBar
Parameters
- $step : int = 1
Return values
ProgressBarfinish()
Finish the progress bar
public
finish() : ProgressBar
Return values
ProgressBargetCurrent()
Get the current progress
public
getCurrent() : int
Return values
intgetTotal()
Get the total number of steps
public
getTotal() : int
Return values
intisFinished()
Determine if the progress bar has finished
public
isFinished() : bool
Return values
boolsetChars()
Set the bar characters
public
setChars([string $barChar = '=' ][, string $progressChar = '>' ][, string $emptyChar = ' ' ]) : ProgressBar
Parameters
- $barChar : string = '='
- $progressChar : string = '>'
- $emptyChar : string = ' '
Return values
ProgressBarsetColor()
Set the color of the filled portion of the bar
public
setColor(int|null $fg[, int|null $bg = null ]) : ProgressBar
Parameters
- $fg : int|null
- $bg : int|null = null
Return values
ProgressBarsetIndent()
Set the indent prefix
public
setIndent(string $indent) : ProgressBar
Parameters
- $indent : string
Return values
ProgressBarsetMessage()
Set the leading message
public
setMessage(string|null $message) : ProgressBar
Parameters
- $message : string|null
Return values
ProgressBarsetProgress()
Set the current progress
public
setProgress(int $current) : ProgressBar
Parameters
- $current : int
Return values
ProgressBarsetWidth()
Set the width of the bar's fill portion
public
setWidth(int $width) : ProgressBar
Parameters
- $width : int
Return values
ProgressBarbuildLine()
Build the progress bar line
protected
buildLine() : string
Return values
stringrender()
Render the progress bar to the console
protected
render() : void