TYPO3  7.6
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
OutputFormatter Class Reference
Inheritance diagram for OutputFormatter:
OutputFormatterInterface

Public Member Functions

 __construct ($decorated=false, array $styles=array())
 
 setDecorated ($decorated)
 
 isDecorated ()
 
 setStyle ($name, OutputFormatterStyleInterface $style)
 
 hasStyle ($name)
 
 getStyle ($name)
 
 format ($message)
 
 getStyleStack ()
 

Static Public Member Functions

static escape ($text)
 

Private Member Functions

 createStyleFromString ($string)
 
 applyCurrentStyle ($text)
 

Private Attributes

 $decorated
 
 $styles = array()
 
 $styleStack
 

Detailed Description

Formatter class for console output.

Author
Konstantin Kudryashov ever..nosp@m.zet@.nosp@m.gmail.nosp@m..com

Definition at line 21 of file OutputFormatter.php.

Constructor & Destructor Documentation

__construct (   $decorated = false,
array  $styles = array() 
)

Initializes console output formatter.

Parameters
bool$decoratedWhether this formatter should actually decorate strings
OutputFormatterStyleInterface[]$styles Array of "name => FormatterStyle" instances

Definition at line 47 of file OutputFormatter.php.

References OutputFormatter\$decorated, OutputFormatter\$styles, and OutputFormatter\setStyle().

Member Function Documentation

applyCurrentStyle (   $text)
private

Applies current style from stack to text, if must be applied.

Parameters
string$textInput text
Returns
string Styled text

Definition at line 238 of file OutputFormatter.php.

References OutputFormatter\isDecorated().

Referenced by OutputFormatter\format().

createStyleFromString (   $string)
private

Tries to create new style instance from string.

Parameters
string$string
Returns
OutputFormatterStyle|bool false if string is not format string

Definition at line 201 of file OutputFormatter.php.

References elseif.

Referenced by OutputFormatter\format().

static escape (   $text)
static

Escapes "<" special char in given text.

Parameters
string$textText to escape
Returns
string Escaped text

Definition at line 34 of file OutputFormatter.php.

Referenced by SymfonyStyle\block(), FormatterHelper\formatBlock(), and OutputFormatterTest\testLGCharEscaping().

format (   $message)

Formats a message according to the given styles.

Parameters
string$messageThe message to style
Returns
string The styled message

Implements OutputFormatterInterface.

Definition at line 143 of file OutputFormatter.php.

References OutputFormatter\applyCurrentStyle(), OutputFormatter\createStyleFromString(), and elseif.

getStyle (   $name)

Gets style options from style with specified name.

Parameters
string$name
Returns
OutputFormatterStyleInterface
Exceptions
\InvalidArgumentExceptionWhen style isn't defined

Implements OutputFormatterInterface.

Definition at line 125 of file OutputFormatter.php.

References OutputFormatter\hasStyle().

getStyleStack ( )
Returns
OutputFormatterStyleStack

Definition at line 189 of file OutputFormatter.php.

References OutputFormatter\$styleStack.

hasStyle (   $name)

Checks if output formatter has style with specified name.

Parameters
string$name
Returns
bool

Implements OutputFormatterInterface.

Definition at line 109 of file OutputFormatter.php.

Referenced by OutputFormatter\getStyle().

isDecorated ( )

Gets the decorated flag.

Returns
bool true if the output will decorate messages, false otherwise

Implements OutputFormatterInterface.

Definition at line 82 of file OutputFormatter.php.

References OutputFormatter\$decorated.

Referenced by OutputFormatter\applyCurrentStyle().

setDecorated (   $decorated)

Sets the decorated flag.

Parameters
bool$decoratedWhether to decorate the messages or not

Implements OutputFormatterInterface.

Definition at line 70 of file OutputFormatter.php.

References OutputFormatter\$decorated.

setStyle (   $name,
OutputFormatterStyleInterface  $style 
)

Sets a new style.

Parameters
string$nameThe style name
OutputFormatterStyleInterface$styleThe style instance

Implements OutputFormatterInterface.

Definition at line 95 of file OutputFormatter.php.

Referenced by OutputFormatter\__construct().

Member Data Documentation

$decorated
private
$styles = array()
private

Definition at line 24 of file OutputFormatter.php.

Referenced by OutputFormatter\__construct().

$styleStack
private

Definition at line 25 of file OutputFormatter.php.

Referenced by OutputFormatter\getStyleStack().