PHP Class Symfony\Component\Console\Helper\ProgressBar

Author: Fabien Potencier ([email protected])
Author: Chris Jones ([email protected])
Afficher le fichier Open project: symfony/symfony Class Usage Examples

Méthodes publiques

Méthode 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

Méthode 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 méthode

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 méthode

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

clear() public méthode

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 méthode

Outputs the current progress string.
public display ( )

finish() public méthode

Finishes the progress output.
public finish ( )

getBarCharacter() public méthode

Gets the bar character.
public getBarCharacter ( ) : string
Résultat string A character

getBarWidth() public méthode

Gets the progress bar width.
public getBarWidth ( ) : integer
Résultat integer The progress bar size

getEmptyBarCharacter() public méthode

Gets the empty bar character.
public getEmptyBarCharacter ( ) : string
Résultat string A character

getFormatDefinition() public static méthode

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

getMaxSteps() public méthode

Gets the progress bar maximal steps.
public getMaxSteps ( ) : integer
Résultat integer The progress bar max steps

getMessage() public méthode

public getMessage ( $name = 'message' )

getPlaceholderFormatterDefinition() public static méthode

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 %)
Résultat callable | null A PHP callable

getProgress() public méthode

Gets the current step position.
public getProgress ( ) : integer
Résultat integer The progress bar step

getProgressCharacter() public méthode

Gets the progress bar character.
public getProgressCharacter ( ) : string
Résultat string A character

getProgressPercent() public méthode

Gets the current progress bar percent.
public getProgressPercent ( ) : float
Résultat float The current progress bar percent

getStartTime() public méthode

Gets the progress bar start time.
public getStartTime ( ) : integer
Résultat integer The progress bar start time

setBarCharacter() public méthode

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

setBarWidth() public méthode

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

setEmptyBarCharacter() public méthode

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

setFormat() public méthode

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

setFormatDefinition() public static méthode

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 méthode

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 méthode

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

setPlaceholderFormatterDefinition() public static méthode

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 méthode

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

setProgressCharacter() public méthode

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

setRedrawFrequency() public méthode

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

start() public méthode

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