PHP Class Symfony\Component\Console\Helper\ProgressBar

Author: Fabien Potencier ([email protected])
Author: Chris Jones ([email protected])
ファイルを表示 Open project: symfony/symfony Class Usage Examples

Public Methods

Method Description
__construct ( Symfony\Component\Console\Output\OutputInterface $output, integer $max )
advance ( integer $step = 1 ) Advances the progress output X steps.
clear ( ) Removes the progress bar from the current line.
display ( ) Outputs the current progress string.
finish ( ) Finishes the progress output.
getBarCharacter ( ) : string Gets the bar character.
getBarWidth ( ) : integer Gets the progress bar width.
getEmptyBarCharacter ( ) : string Gets the empty bar character.
getFormatDefinition ( string $name ) : string | null Gets the format for a given name.
getMaxSteps ( ) : integer Gets the progress bar maximal steps.
getMessage ( $name = 'message' )
getPlaceholderFormatterDefinition ( string $name ) : callable | null Gets the placeholder formatter for a given name.
getProgress ( ) : integer Gets the current step position.
getProgressCharacter ( ) : string Gets the progress bar character.
getProgressPercent ( ) : float Gets the current progress bar percent.
getStartTime ( ) : integer Gets the progress bar start time.
setBarCharacter ( string $char ) Sets the bar character.
setBarWidth ( integer $size ) Sets the progress bar width.
setEmptyBarCharacter ( string $char ) Sets the empty bar character.
setFormat ( string $format ) Sets the progress bar format.
setFormatDefinition ( string $name, string $format ) Sets a format for a given name.
setMessage ( string $message, string $name = 'message' ) Associates a text with a named placeholder.
setOverwrite ( boolean $overwrite ) Sets whether to overwrite the progressbar, false for new line.
setPlaceholderFormatterDefinition ( string $name, callable $callable ) Sets a placeholder formatter for a given name.
setProgress ( integer $step ) Sets the current progress.
setProgressCharacter ( string $char ) Sets the progress bar character.
setRedrawFrequency ( integer | float $freq ) Sets the redraw frequency.
start ( integer | null $max = null ) Starts the progress output.

Private Methods

Method Description
buildLine ( ) : string
determineBestFormat ( )
getStepWidth ( ) : integer Gets the progress bar step width.
initFormats ( )
initPlaceholderFormatters ( )
overwrite ( string $message ) Overwrites a previous message to the output.
setMaxSteps ( integer $max ) Sets the progress bar maximal steps.
setRealFormat ( string $format ) Sets the progress bar format.

Method Details

__construct() public method

public __construct ( Symfony\Component\Console\Output\OutputInterface $output, integer $max )
$output Symfony\Component\Console\Output\OutputInterface An OutputInterface instance
$max integer Maximum steps (0 if unknown)

advance() public method

Advances the progress output X steps.
public advance ( integer $step = 1 )
$step integer Number of steps to advance

clear() public method

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

display() public method

Outputs the current progress string.
public display ( )

finish() public method

Finishes the progress output.
public finish ( )

getBarCharacter() public method

Gets the bar character.
public getBarCharacter ( ) : string
return string A character

getBarWidth() public method

Gets the progress bar width.
public getBarWidth ( ) : integer
return integer The progress bar size

getEmptyBarCharacter() public method

Gets the empty bar character.
public getEmptyBarCharacter ( ) : string
return string A character

getFormatDefinition() public static method

Gets the format for a given name.
public static getFormatDefinition ( string $name ) : string | null
$name string The format name
return string | null A format string

getMaxSteps() public method

Gets the progress bar maximal steps.
public getMaxSteps ( ) : integer
return integer The progress bar max steps

getMessage() public method

public getMessage ( $name = 'message' )

getPlaceholderFormatterDefinition() public static method

Gets the placeholder formatter for a given name.
public static getPlaceholderFormatterDefinition ( string $name ) : callable | null
$name string The placeholder name (including the delimiter char like %)
return callable | null A PHP callable

getProgress() public method

Gets the current step position.
public getProgress ( ) : integer
return integer The progress bar step

getProgressCharacter() public method

Gets the progress bar character.
public getProgressCharacter ( ) : string
return string A character

getProgressPercent() public method

Gets the current progress bar percent.
public getProgressPercent ( ) : float
return float The current progress bar percent

getStartTime() public method

Gets the progress bar start time.
public getStartTime ( ) : integer
return integer The progress bar start time

setBarCharacter() public method

Sets the bar character.
public setBarCharacter ( string $char )
$char string A character

setBarWidth() public method

Sets the progress bar width.
public setBarWidth ( integer $size )
$size integer The progress bar size

setEmptyBarCharacter() public method

Sets the empty bar character.
public setEmptyBarCharacter ( string $char )
$char string A character

setFormat() public method

Sets the progress bar format.
public setFormat ( string $format )
$format string The format

setFormatDefinition() public static method

This method also allow you to override an existing format.
public static setFormatDefinition ( string $name, string $format )
$name string The format name
$format string A format string

setMessage() public method

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 %).
public setMessage ( string $message, string $name = 'message' )
$message string The text to associate with the placeholder
$name string The name of the placeholder

setOverwrite() public method

Sets whether to overwrite the progressbar, false for new line.
public setOverwrite ( boolean $overwrite )
$overwrite boolean

setPlaceholderFormatterDefinition() public static method

This method also allow you to override an existing placeholder.
public static setPlaceholderFormatterDefinition ( string $name, callable $callable )
$name string The placeholder name (including the delimiter char like %)
$callable callable A PHP callable

setProgress() public method

Sets the current progress.
public setProgress ( integer $step )
$step integer The current progress

setProgressCharacter() public method

Sets the progress bar character.
public setProgressCharacter ( string $char )
$char string A character

setRedrawFrequency() public method

Sets the redraw frequency.
public setRedrawFrequency ( integer | float $freq )
$freq integer | float The frequency in steps

start() public method

Starts the progress output.
public start ( integer | null $max = null )
$max integer | null Number of steps to complete the bar (0 if indeterminate), null to leave unchanged