PHP Class ProgressBar\Manager

Author: guiguiboy
Exibir arquivo Open project: guiguiboy/php-cli-progress-bar Class Usage Examples

Protected Properties

Property Type Description
$format Default format for the progress bar
$registry Instance of Registry. Used to store metrics.
$replacementRules array Stores replacement rules

Public Methods

Method Description
__construct ( $current, $max, $width = 80, $doneBarElementCharacter = '=', $remainingBarElementCharacter = '-', $currentPositionCharacter = '>' ) Class constructor
addReplacementRule ( string $tag, integer $priority, callable $callable ) Register a replacement rule
advance ( ) Advances the progress bar with one step.
getFormat ( ) : string Returns the current output format
getRegistry ( ) : Registry Returns the Registry
setFormat ( string $string ) Sette le format d'affichage
setRegistry ( Registry $registry ) Sets a Registry
update ( integer $current ) Updates current progress Saves new metrics in the registry

Protected Methods

Method Description
clearRightCharacters ( string $buffer ) : string Clears line remaining characters so that buffer length always equals to max width.
display ( boolean $lineReturn ) Prints the progress bar
registerDefaultReplacementRules ( ) Allows to define replacements functions for the format string If you wish to add custom replacements rules, extend this class, and add overload this method.

Method Details

__construct() public method

Class constructor
public __construct ( $current, $max, $width = 80, $doneBarElementCharacter = '=', $remainingBarElementCharacter = '-', $currentPositionCharacter = '>' )

addReplacementRule() public method

Register a replacement rule
public addReplacementRule ( string $tag, integer $priority, callable $callable )
$tag string
$priority integer
$callable callable

advance() public method

Advances the progress bar with one step.
public advance ( )

clearRightCharacters() protected method

registry->getValue('width') -1 stands for the control character \r or \n that will be added to the buffer.
protected clearRightCharacters ( string $buffer ) : string
$buffer string
return string

display() protected method

Prints the progress bar
protected display ( boolean $lineReturn )
$lineReturn boolean

getFormat() public method

Returns the current output format
public getFormat ( ) : string
return string

getRegistry() public method

Returns the Registry
public getRegistry ( ) : Registry
return Registry

registerDefaultReplacementRules() protected method

Each replacement has a priority and a closure

setFormat() public method

Sette le format d'affichage
public setFormat ( string $string )
$string string

setRegistry() public method

Sets a Registry
public setRegistry ( Registry $registry )
$registry Registry

update() public method

Updates current progress Saves new metrics in the registry
public update ( integer $current )
$current integer

Property Details

$format protected_oe property

Default format for the progress bar
protected $format

$registry protected_oe property

Instance of Registry. Used to store metrics.
protected $registry

$replacementRules protected_oe property

Stores replacement rules
protected array $replacementRules
return array