PHP Class Symfony\Component\Console\Formatter\OutputFormatter

Author: Konstantin Kudryashov ([email protected])
Inheritance: implements Symfony\Component\Console\Formatter\OutputFormatterInterface
ファイルを表示 Open project: symfony/symfony Class Usage Examples

Public Methods

Method Description
__construct ( boolean $decorated = false, array $styles = [] ) Initializes console output formatter.
escape ( string $text ) : string Escapes "<" special char in given text.
escapeTrailingBackslash ( string $text ) : string Escapes trailing "\" in given text.
format ( string $message ) : string Formats a message according to the given styles.
getStyle ( string $name ) : Symfony\Component\Console\Formatter\OutputFormatterStyleInterface Gets style options from style with specified name.
getStyleStack ( ) : Symfony\Component\Console\Formatter\OutputFormatterStyleStack
hasStyle ( string $name ) : boolean Checks if output formatter has style with specified name.
isDecorated ( ) : boolean Gets the decorated flag.
setDecorated ( boolean $decorated ) Sets the decorated flag.
setStyle ( string $name, Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $style ) Sets a new style.

Private Methods

Method Description
applyCurrentStyle ( string $text ) : string Applies current style from stack to text, if must be applied.
createStyleFromString ( string $string ) : Symfony\Component\Console\Formatter\OutputFormatterStyle | boolean Tries to create new style instance from string.

Method Details

__construct() public method

Initializes console output formatter.
public __construct ( boolean $decorated = false, array $styles = [] )
$decorated boolean Whether this formatter should actually decorate strings
$styles array Array of "name => FormatterStyle" instances

escape() public static method

Escapes "<" special char in given text.
public static escape ( string $text ) : string
$text string Text to escape
return string Escaped text

escapeTrailingBackslash() public static method

Escapes trailing "\" in given text.
public static escapeTrailingBackslash ( string $text ) : string
$text string Text to escape
return string Escaped text

format() public method

Formats a message according to the given styles.
public format ( string $message ) : string
$message string The message to style
return string The styled message

getStyle() public method

Gets style options from style with specified name.
public getStyle ( string $name ) : Symfony\Component\Console\Formatter\OutputFormatterStyleInterface
$name string
return Symfony\Component\Console\Formatter\OutputFormatterStyleInterface

getStyleStack() public method

public getStyleStack ( ) : Symfony\Component\Console\Formatter\OutputFormatterStyleStack
return Symfony\Component\Console\Formatter\OutputFormatterStyleStack

hasStyle() public method

Checks if output formatter has style with specified name.
public hasStyle ( string $name ) : boolean
$name string
return boolean

isDecorated() public method

Gets the decorated flag.
public isDecorated ( ) : boolean
return boolean true if the output will decorate messages, false otherwise

setDecorated() public method

Sets the decorated flag.
public setDecorated ( boolean $decorated )
$decorated boolean Whether to decorate the messages or not

setStyle() public method

Sets a new style.
public setStyle ( string $name, Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $style )
$name string The style name
$style Symfony\Component\Console\Formatter\OutputFormatterStyleInterface The style instance