OutputFormatterStyle
in package
implements
OutputFormatterStyleInterface
Formatter style class for defining styles.
Tags
Table of Contents
Interfaces
- OutputFormatterStyleInterface
- Formatter style interface for defining styles.
Properties
- $availableBackgroundColors : mixed
- $availableForegroundColors : mixed
- $availableOptions : mixed
- $background : mixed
- $foreground : mixed
- $handlesHrefGracefully : mixed
- $href : mixed
- $options : mixed
Methods
- __construct() : mixed
- Initializes output formatter style.
- apply() : string
- Applies the style to a given text.
- setBackground() : mixed
- Sets style background color.
- setForeground() : mixed
- Sets style foreground color.
- setHref() : void
- setOption() : mixed
- Sets some specific style option.
- setOptions() : mixed
- Sets multiple style options at once.
- unsetOption() : mixed
- Unsets some specific style option.
Properties
$availableBackgroundColors
private
static mixed
$availableBackgroundColors
= ['black' => ['set' => 40, 'unset' => 49], 'red' => ['set' => 41, 'unset' => 49], 'green' => ['set' => 42, 'unset' => 49], 'yellow' => ['set' => 43, 'unset' => 49], 'blue' => ['set' => 44, 'unset' => 49], 'magenta' => ['set' => 45, 'unset' => 49], 'cyan' => ['set' => 46, 'unset' => 49], 'white' => ['set' => 47, 'unset' => 49], 'default' => ['set' => 49, 'unset' => 49]]
$availableForegroundColors
private
static mixed
$availableForegroundColors
= ['black' => ['set' => 30, 'unset' => 39], 'red' => ['set' => 31, 'unset' => 39], 'green' => ['set' => 32, 'unset' => 39], 'yellow' => ['set' => 33, 'unset' => 39], 'blue' => ['set' => 34, 'unset' => 39], 'magenta' => ['set' => 35, 'unset' => 39], 'cyan' => ['set' => 36, 'unset' => 39], 'white' => ['set' => 37, 'unset' => 39], 'default' => ['set' => 39, 'unset' => 39]]
$availableOptions
private
static mixed
$availableOptions
= ['bold' => ['set' => 1, 'unset' => 22], 'underscore' => ['set' => 4, 'unset' => 24], 'blink' => ['set' => 5, 'unset' => 25], 'reverse' => ['set' => 7, 'unset' => 27], 'conceal' => ['set' => 8, 'unset' => 28]]
$background
private
mixed
$background
$foreground
private
mixed
$foreground
$handlesHrefGracefully
private
mixed
$handlesHrefGracefully
$href
private
mixed
$href
$options
private
mixed
$options
= []
Methods
__construct()
Initializes output formatter style.
public
__construct([string|null $foreground = null ][, string|null $background = null ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $foreground : string|null = null
-
The style foreground color name
- $background : string|null = null
-
The style background color name
- $options : array<string|int, mixed> = []
apply()
Applies the style to a given text.
public
apply(mixed $text) : string
Parameters
- $text : mixed
-
The text to style
Return values
stringsetBackground()
Sets style background color.
public
setBackground([mixed $color = null ]) : mixed
Parameters
- $color : mixed = null
-
The color name
setForeground()
Sets style foreground color.
public
setForeground([mixed $color = null ]) : mixed
Parameters
- $color : mixed = null
-
The color name
setHref()
public
setHref(string $url) : void
Parameters
- $url : string
setOption()
Sets some specific style option.
public
setOption(mixed $option) : mixed
Parameters
- $option : mixed
-
The option name
setOptions()
Sets multiple style options at once.
public
setOptions(array<string|int, mixed> $options) : mixed
Parameters
- $options : array<string|int, mixed>
unsetOption()
Unsets some specific style option.
public
unsetOption(mixed $option) : mixed
Parameters
- $option : mixed
-
The option name