W3cubDocs

/Symfony 2.8

Symfony\Component\Console\Formatter\OutputFormatter

class OutputFormatter implements OutputFormatterInterface

Formatter class for console output.

Methods

static string escape(string $text)

Escapes "<" special char in given text.

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

Initializes console output formatter.

setDecorated(bool $decorated)

Sets the decorated flag.

bool isDecorated()

Gets the decorated flag.

setStyle(string $name, OutputFormatterStyleInterface $style)

Sets a new style.

bool hasStyle(string $name)

Checks if output formatter has style with specified name.

OutputFormatterStyleInterface getStyle(string $name)

Gets style options from style with specified name.

string format(string $message)

Formats a message according to the given styles.

OutputFormatterStyleStack getStyleStack()

Details

static public string escape(string $text)

Escapes "<" special char in given text.

Parameters

string $text Text to escape

Return Value

string Escaped text

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

Initializes console output formatter.

Parameters

bool $decorated Whether this formatter should actually decorate strings
array $styles Array of "name => FormatterStyle" instances

public setDecorated(bool $decorated)

Sets the decorated flag.

Parameters

bool $decorated Whether to decorate the messages or not

public bool isDecorated()

Gets the decorated flag.

Return Value

bool true if the output will decorate messages, false otherwise

public setStyle(string $name, OutputFormatterStyleInterface $style)

Sets a new style.

Parameters

string $name The style name
OutputFormatterStyleInterface $style The style instance

public bool hasStyle(string $name)

Checks if output formatter has style with specified name.

Parameters

string $name

Return Value

bool

public OutputFormatterStyleInterface getStyle(string $name)

Gets style options from style with specified name.

Parameters

string $name

Return Value

OutputFormatterStyleInterface

Exceptions

InvalidArgumentException When style isn't defined

public string format(string $message)

Formats a message according to the given styles.

Parameters

string $message The message to style

Return Value

string The styled message

public OutputFormatterStyleStack getStyleStack()

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/Console/Formatter/OutputFormatter.html