Documentation

OutputFormatter
in package
implements OutputFormatterInterface

Formatter class for console output.

Tags
author

Konstantin Kudryashov ever.zet@gmail.com

Table of Contents

Interfaces

OutputFormatterInterface
Formatter interface for console output.

Properties

$decorated  : mixed
$styles  : mixed
$styleStack  : mixed

Methods

__construct()  : mixed
Initializes console output formatter.
escape()  : string
Escapes "<" special char in given text.
format()  : string
Formats a message according to the given styles.
getStyle()  : OutputFormatterStyleInterface
Gets style options from style with specified name.
getStyleStack()  : OutputFormatterStyleStack
hasStyle()  : bool
Checks if output formatter has style with specified name.
isDecorated()  : bool
Gets the decorated flag.
setDecorated()  : mixed
Sets the decorated flag.
setStyle()  : mixed
Sets a new style.
applyCurrentStyle()  : string
Applies current style from stack to text, if must be applied.
createStyleFromString()  : OutputFormatterStyle|false
Tries to create new style instance from string.

Properties

Methods

__construct()

Initializes console output formatter.

public __construct([bool $decorated = false ][, array<string|int, OutputFormatterStyleInterface$styles = array() ]) : mixed
Parameters
$decorated : bool = false

Whether this formatter should actually decorate strings

$styles : array<string|int, OutputFormatterStyleInterface> = array()

Array of "name => FormatterStyle" instances

escape()

Escapes "<" special char in given text.

public static escape(string $text) : string
Parameters
$text : string

Text to escape

Return values
string

Escaped text

format()

Formats a message according to the given styles.

public format(mixed $message) : string
Parameters
$message : mixed

The message to style

Return values
string

The styled message

hasStyle()

Checks if output formatter has style with specified name.

public hasStyle(mixed $name) : bool
Parameters
$name : mixed
Return values
bool

isDecorated()

Gets the decorated flag.

public isDecorated() : bool
Return values
bool

true if the output will decorate messages, false otherwise

setDecorated()

Sets the decorated flag.

public setDecorated(mixed $decorated) : mixed
Parameters
$decorated : mixed

Whether to decorate the messages or not

applyCurrentStyle()

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

private applyCurrentStyle(string $text) : string
Parameters
$text : string

Input text

Return values
string

Styled text


        
On this page

Search results