HtmlOutputFormatter
extends OutputFormatter
in package
Formatter class for console output.
Tags
Table of Contents
- $availableBackgroundColors : mixed
- $availableForegroundColors : mixed
- $availableOptions : mixed
- $decorated : mixed
- $styles : mixed
- $styleStack : mixed
- __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.
- formatHtml() : mixed
Properties
$availableBackgroundColors
private
static mixed
$availableBackgroundColors
= array(40 => 'black', 41 => 'red', 42 => 'green', 43 => 'yellow', 44 => 'blue', 45 => 'magenta', 46 => 'cyan', 47 => 'white')
$availableForegroundColors
private
static mixed
$availableForegroundColors
= array(30 => 'black', 31 => 'red', 32 => 'green', 33 => 'yellow', 34 => 'blue', 35 => 'magenta', 36 => 'cyan', 37 => 'white')
$availableOptions
private
static mixed
$availableOptions
= array(1 => 'bold', 4 => 'underscore')
$decorated
private
mixed
$decorated
$styles
private
mixed
$styles
= []
$styleStack
private
mixed
$styleStack
Methods
__construct()
Initializes console output formatter.
public
__construct([array<string|int, mixed> $styles = array() ]) : mixed
Parameters
- $styles : array<string|int, mixed> = array()
-
Array of "name => FormatterStyle" instances
Return values
mixed —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
getStyle()
Gets style options from style with specified name.
public
getStyle(mixed $name) : OutputFormatterStyleInterface
Parameters
- $name : mixed
Return values
OutputFormatterStyleInterface —getStyleStack()
public
getStyleStack() : OutputFormatterStyleStack
Return values
OutputFormatterStyleStack —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
Return values
mixed —setStyle()
Sets a new style.
public
setStyle(mixed $name, OutputFormatterStyleInterface $style) : mixed
Parameters
- $name : mixed
-
The style name
- $style : OutputFormatterStyleInterface
-
The style instance
Return values
mixed —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
createStyleFromString()
Tries to create new style instance from string.
private
createStyleFromString(string $string) : OutputFormatterStyle|false
Parameters
- $string : string
Return values
OutputFormatterStyle|false —false if string is not format string
formatHtml()
private
formatHtml(mixed $matches) : mixed
Parameters
- $matches : mixed