Text UI
A simple and fast way to take user input and display output in text mode using PHP.
Loading...
Searching...
No Matches
Progress Class Reference
Inheritance diagram for Progress:
MeterInterface

Public Member Functions

 __construct (float|int $maxValue)
 
 update (float|int $currentValue)
 
 end ()
 
 setPercentPrecision (int $precision)
 
 setUnitFormatter (?object $formatter)
 
 init ()
 
 setBarChar (string $char)
 

Data Fields

bool $units = true
 
bool $times = true
 

Protected Member Functions

 getProgressStr (int $maxWidth)
 
 getPercentStr ()
 
 getElapsedTimeStr ()
 
 getRemainingTimeStr ()
 
 getTimesStr ()
 
 getUnitsStr ()
 
 setCurrentValue (float|int $value)
 

Protected Attributes

readonly float int $maxValue
 
float int $currentValue = 0
 
DateTime $startTime = null
 
object $unitFormatter = null
 
int $percentPrecision = 0
 
string $barChar = '|'
 

Detailed Description

A progress bar with percentage and optional time and count indicators.

Author
everton3x

Definition at line 17 of file Progress.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( float|int $maxValue)

Definition at line 40 of file Progress.php.

Member Function Documentation

◆ end()

end ( )

Finalizes the progress bar ensuring that the total of 100% is reached.

Definition at line 85 of file Progress.php.

◆ getElapsedTimeStr()

getElapsedTimeStr ( )
protected
Returns
string
Exceptions
DateException@SuppressWarnings(PHPMD.StaticAccess)

Definition at line 126 of file Progress.php.

◆ getPercentStr()

getPercentStr ( )
protected

Definition at line 114 of file Progress.php.

◆ getProgressStr()

getProgressStr ( int $maxWidth)
protected

Definition at line 91 of file Progress.php.

◆ getRemainingTimeStr()

getRemainingTimeStr ( )
protected
Returns
string
Exceptions
DateException@SuppressWarnings(PHPMD.StaticAccess)

Definition at line 154 of file Progress.php.

◆ getTimesStr()

getTimesStr ( )
protected

Definition at line 197 of file Progress.php.

◆ getUnitsStr()

getUnitsStr ( )
protected

Definition at line 204 of file Progress.php.

◆ init()

init ( )

Starts the progress bar.

Returns
void

Definition at line 238 of file Progress.php.

◆ setBarChar()

setBarChar ( string $char)

Sets a unique character to be used in the progress bar indicator.

Parameters
string$char
Returns
Progress
Exceptions
InvalidArgumentException

Definition at line 263 of file Progress.php.

◆ setCurrentValue()

setCurrentValue ( float|int $value)
protected

Definition at line 243 of file Progress.php.

◆ setPercentPrecision()

setPercentPrecision ( int $precision)

Sets the decimal precision of the percentage indicator.

Parameters
int$precision
Returns
Progress
Exceptions
InvalidArgumentException

Definition at line 105 of file Progress.php.

◆ setUnitFormatter()

setUnitFormatter ( ?object $formatter)

Function to format the values ​​of the value indicator. It must be a function that receives a value as an argument and returns that formatted value.

Parameters
null | object$formatter
Returns
Progress

Definition at line 227 of file Progress.php.

◆ update()

update ( float|int $currentValue)
Parameters
float | int$currentValue
Returns
void @SuppressWarnings(PHPMD.StaticAccess)

Definition at line 54 of file Progress.php.

Field Documentation

◆ $barChar

string $barChar = '|'
protected

Definition at line 24 of file Progress.php.

◆ $currentValue

float int $currentValue = 0
protected

Definition at line 20 of file Progress.php.

◆ $maxValue

readonly float int $maxValue
protected

Definition at line 19 of file Progress.php.

◆ $percentPrecision

int $percentPrecision = 0
protected

Definition at line 23 of file Progress.php.

◆ $startTime

DateTime $startTime = null
protected

Definition at line 21 of file Progress.php.

◆ $times

bool $times = true

Definition at line 38 of file Progress.php.

◆ $unitFormatter

object $unitFormatter = null
protected

Definition at line 22 of file Progress.php.

◆ $units

bool $units = true

Definition at line 31 of file Progress.php.


The documentation for this class was generated from the following file: