TYPO3  7.6
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ProgressBar Class Reference

Public Member Functions

 __construct (OutputInterface $output, $max=0)
 
 setMessage ($message, $name= 'message')
 
 getMessage ($name= 'message')
 
 getStartTime ()
 
 getMaxSteps ()
 
 getStep ()
 
 getProgress ()
 
 getStepWidth ()
 
 getProgressPercent ()
 
 setBarWidth ($size)
 
 getBarWidth ()
 
 setBarCharacter ($char)
 
 getBarCharacter ()
 
 setEmptyBarCharacter ($char)
 
 getEmptyBarCharacter ()
 
 setProgressCharacter ($char)
 
 getProgressCharacter ()
 
 setFormat ($format)
 
 setRedrawFrequency ($freq)
 
 start ($max=null)
 
 advance ($step=1)
 
 setCurrent ($step)
 
 setOverwrite ($overwrite)
 
 setProgress ($step)
 
 finish ()
 
 display ()
 
 clear ()
 

Static Public Member Functions

static setPlaceholderFormatterDefinition ($name, $callable)
 
static getPlaceholderFormatterDefinition ($name)
 
static setFormatDefinition ($name, $format)
 
static getFormatDefinition ($name)
 

Private Member Functions

 setMaxSteps ($max)
 
 overwrite ($message)
 
 determineBestFormat ()
 

Static Private Member Functions

static initPlaceholderFormatters ()
 
static initFormats ()
 

Private Attributes

 $barWidth = 28
 
 $barChar
 
 $emptyBarChar = '-'
 
 $progressChar = '>'
 
 $format = null
 
 $redrawFreq = 1
 
 $output
 
 $step = 0
 
 $max
 
 $startTime
 
 $stepWidth
 
 $percent = 0.0
 
 $lastMessagesLength = 0
 
 $formatLineCount
 
 $messages
 
 $overwrite = true
 

Static Private Attributes

static $formatters
 
static $formats
 

Detailed Description

The ProgressBar provides helpers to display progress output.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com
Chris Jones leeke.nosp@m.d@gm.nosp@m.ail.c.nosp@m.om

Definition at line 22 of file ProgressBar.php.

Constructor & Destructor Documentation

__construct ( OutputInterface  $output,
  $max = 0 
)

Constructor.

Parameters
OutputInterface$outputAn OutputInterface instance
int$maxMaximum steps (0 if unknown)

Definition at line 55 of file ProgressBar.php.

References ProgressBar\$max, ProgressBar\$output, ProgressBar\determineBestFormat(), ProgressBar\overwrite(), ProgressBar\setFormat(), ProgressBar\setMaxSteps(), and ProgressBar\setRedrawFrequency().

Member Function Documentation

advance (   $step = 1)

Advances the progress output X steps.

Parameters
int$stepNumber of steps to advance
Exceptions
\LogicException

Definition at line 355 of file ProgressBar.php.

References ProgressBar\$step, and ProgressBar\setProgress().

Referenced by ProgressBarTest\testAnsiColorsAndEmojis().

clear ( )

Removes the progress bar from the current line.

This is useful if you wish to write some output while a progress bar is running. Call display() to show the progress bar again.

Definition at line 467 of file ProgressBar.php.

References ProgressBar\overwrite().

determineBestFormat ( )
private
display ( )
finish ( )

Finishes the progress output.

Definition at line 416 of file ProgressBar.php.

References ProgressBar\$step, ProgressBar\overwrite(), and ProgressBar\setProgress().

Referenced by ProgressBarTest\testAnsiColorsAndEmojis().

getBarCharacter ( )

Gets the bar character.

Returns
string A character

Definition at line 252 of file ProgressBar.php.

References ProgressBar\$barChar, and ProgressBar\$emptyBarChar.

Referenced by ProgressBar\initPlaceholderFormatters().

getBarWidth ( )

Gets the progress bar width.

Returns
int The progress bar size

Definition at line 232 of file ProgressBar.php.

References ProgressBar\$barWidth.

Referenced by ProgressBar\initPlaceholderFormatters().

getEmptyBarCharacter ( )

Gets the empty bar character.

Returns
string A character

Definition at line 276 of file ProgressBar.php.

References ProgressBar\$emptyBarChar.

Referenced by ProgressBar\initPlaceholderFormatters().

static getFormatDefinition (   $name)
static

Gets the format for a given name.

Parameters
string$nameThe format name
Returns
string|null A format string

Definition at line 132 of file ProgressBar.php.

getMaxSteps ( )

Gets the progress bar maximal steps.

Returns
int The progress bar max steps

Definition at line 166 of file ProgressBar.php.

References ProgressBar\$max.

Referenced by ProgressBar\initPlaceholderFormatters(), and ProgressBarTest\testAddingPlaceholderFormatter().

getMessage (   $name = 'message')

Definition at line 146 of file ProgressBar.php.

static getPlaceholderFormatterDefinition (   $name)
static

Gets the placeholder formatter for a given name.

Parameters
string$nameThe placeholder name (including the delimiter char like %)
Returns
callable|null A PHP callable

Definition at line 99 of file ProgressBar.php.

getProgress ( )

Gets the current step position.

Returns
int The progress bar step

Definition at line 190 of file ProgressBar.php.

References ProgressBar\$step.

Referenced by ProgressBar\getStep(), ProgressBar\initPlaceholderFormatters(), and ProgressBarTest\testAddingPlaceholderFormatter().

getProgressCharacter ( )

Gets the progress bar character.

Returns
string A character

Definition at line 296 of file ProgressBar.php.

References ProgressBar\$progressChar.

Referenced by ProgressBar\initPlaceholderFormatters().

getProgressPercent ( )

Gets the current progress bar percent.

Returns
float The current progress bar percent

Definition at line 212 of file ProgressBar.php.

References ProgressBar\$percent.

Referenced by ProgressBar\initPlaceholderFormatters().

getStartTime ( )

Gets the progress bar start time.

Returns
int The progress bar start time

Definition at line 156 of file ProgressBar.php.

References ProgressBar\$startTime.

Referenced by ProgressBar\initPlaceholderFormatters().

getStep ( )

Gets the progress bar step.

Deprecated:
since version 2.6, to be removed in 3.0. Use getProgress() instead.
Returns
int The progress bar step

Definition at line 178 of file ProgressBar.php.

References ProgressBar\getProgress().

getStepWidth ( )

Gets the progress bar step width.

Definition at line 202 of file ProgressBar.php.

References ProgressBar\$stepWidth.

Referenced by ProgressBar\initPlaceholderFormatters().

static initFormats ( )
staticprivate

Definition at line 599 of file ProgressBar.php.

static initPlaceholderFormatters ( )
staticprivate
overwrite (   $message)
private

Overwrites a previous message to the output.

Parameters
string$messageThe message

Definition at line 492 of file ProgressBar.php.

References elseif, and Helper\strlenWithoutDecoration().

Referenced by ProgressBar\__construct(), ProgressBar\clear(), ProgressBar\display(), ProgressBar\finish(), and ProgressBar\setOverwrite().

setBarCharacter (   $char)

Sets the bar character.

Parameters
string$charA character

Definition at line 242 of file ProgressBar.php.

Referenced by ProgressBarTest\testAnsiColorsAndEmojis().

setBarWidth (   $size)

Sets the progress bar width.

Parameters
int$sizeThe progress bar size

Definition at line 222 of file ProgressBar.php.

setCurrent (   $step)

Sets the current progress.

Deprecated:
since version 2.6, to be removed in 3.0. Use setProgress() instead.
Parameters
int$stepThe current progress
Exceptions
\LogicException

Definition at line 369 of file ProgressBar.php.

References ProgressBar\$step, and ProgressBar\setProgress().

setEmptyBarCharacter (   $char)

Sets the empty bar character.

Parameters
string$charA character

Definition at line 266 of file ProgressBar.php.

Referenced by ProgressBarTest\testAnsiColorsAndEmojis().

setFormat (   $format)

Sets the progress bar format.

Parameters
string$formatThe format

Definition at line 306 of file ProgressBar.php.

References ProgressBar\$format, and elseif.

Referenced by ProgressBar\__construct(), and ProgressBarTest\testAnsiColorsAndEmojis().

static setFormatDefinition (   $name,
  $format 
)
static

Sets a format for a given name.

This method also allow you to override an existing format.

Parameters
string$nameThe format name
string$formatA format string

Definition at line 116 of file ProgressBar.php.

References ProgressBar\$format.

setMaxSteps (   $max)
private

Sets the progress bar maximal steps.

Parameters
intThe progress bar max steps

Definition at line 481 of file ProgressBar.php.

References ProgressBar\$max, and Helper\strlen().

Referenced by ProgressBar\__construct(), and ProgressBar\start().

setMessage (   $message,
  $name = 'message' 
)

Definition at line 141 of file ProgressBar.php.

Referenced by ProgressBarTest\testAnsiColorsAndEmojis().

setOverwrite (   $overwrite)

Sets whether to overwrite the progressbar, false for new line.

Parameters
bool$overwrite

Definition at line 381 of file ProgressBar.php.

References ProgressBar\$overwrite, and ProgressBar\overwrite().

static setPlaceholderFormatterDefinition (   $name,
  $callable 
)
static

Sets a placeholder formatter for a given name.

This method also allow you to override an existing placeholder.

Parameters
string$nameThe placeholder name (including the delimiter char like %)
callable$callableA PHP callable

Definition at line 83 of file ProgressBar.php.

Referenced by ProgressBarTest\testAddingPlaceholderFormatter(), and ProgressBarTest\testAnsiColorsAndEmojis().

setProgress (   $step)

Sets the current progress.

Parameters
int$stepThe current progress
Exceptions
\LogicException

Definition at line 393 of file ProgressBar.php.

References ProgressBar\$step, and ProgressBar\display().

Referenced by ProgressBar\advance(), ProgressBar\finish(), and ProgressBar\setCurrent().

setProgressCharacter (   $char)

Sets the progress bar character.

Parameters
string$charA character

Definition at line 286 of file ProgressBar.php.

Referenced by ProgressBarTest\testAnsiColorsAndEmojis().

setRedrawFrequency (   $freq)

Sets the redraw frequency.

Parameters
int$freqThe frequency in steps

Definition at line 325 of file ProgressBar.php.

Referenced by ProgressBar\__construct().

start (   $max = null)

Starts the progress output.

Parameters
int | null$maxNumber of steps to complete the bar (0 if indeterminate), null to leave unchanged

Definition at line 335 of file ProgressBar.php.

References ProgressBar\$max, ProgressBar\display(), and ProgressBar\setMaxSteps().

Referenced by ProgressBarTest\testAnsiColorsAndEmojis().

Member Data Documentation

$barChar
private

Definition at line 26 of file ProgressBar.php.

Referenced by ProgressBar\getBarCharacter().

$barWidth = 28
private

Definition at line 25 of file ProgressBar.php.

Referenced by ProgressBar\getBarWidth().

$emptyBarChar = '-'
private
$format = null
private
$formatLineCount
private

Definition at line 42 of file ProgressBar.php.

$formats
staticprivate

Definition at line 47 of file ProgressBar.php.

$formatters
staticprivate

Definition at line 46 of file ProgressBar.php.

$lastMessagesLength = 0
private

Definition at line 41 of file ProgressBar.php.

$max
private
$messages
private

Definition at line 43 of file ProgressBar.php.

Referenced by ProgressBar\display().

$output
private
$overwrite = true
private

Definition at line 44 of file ProgressBar.php.

Referenced by ProgressBar\setOverwrite().

$percent = 0.0
private

Definition at line 40 of file ProgressBar.php.

Referenced by ProgressBar\getProgressPercent().

$progressChar = '>'
private

Definition at line 28 of file ProgressBar.php.

Referenced by ProgressBar\getProgressCharacter().

$redrawFreq = 1
private

Definition at line 30 of file ProgressBar.php.

$startTime
private

Definition at line 38 of file ProgressBar.php.

Referenced by ProgressBar\getStartTime().

$step = 0
private
$stepWidth
private

Definition at line 39 of file ProgressBar.php.

Referenced by ProgressBar\getStepWidth().