Color
in package
Horde_Cli API for basic command-line functionality/checks.
Tags
Table of Contents
- FORMAT_HTML = 3
- HTML compatible color formatting.
- FORMAT_NONE = 0
- No color formatting.
- FORMAT_VT100 = 2
- VT100 compatible color formatting.
- FORMAT_XTERM = 1
- xterm compatible color formatting.
- $_format : mixed
- The color formatting being used.
- __call() : string
- Returns a colored version of $text, with the method name specifying the color:
- __construct() : mixed
- Constructor.
- background() : string
- Returns a version of $text with a colored background.
- bold() : string
- Returns a bold version of $text.
- color() : string
- Returns a colored version of $text.
- format() : string
- Returns a version of $text with a colored foreground and background.
- remove() : string
- Removes all color formatting from a text.
- _backgroundColors() : array<string|int, mixed>
- Returns the xterm-compatible background color sequences.
- _foregroundColors() : array<string|int, mixed>
- Returns the xterm-compatible foreground color sequences.
Constants
FORMAT_HTML
HTML compatible color formatting.
public
mixed
FORMAT_HTML
= 3
FORMAT_NONE
No color formatting.
public
mixed
FORMAT_NONE
= 0
FORMAT_VT100
VT100 compatible color formatting.
public
mixed
FORMAT_VT100
= 2
FORMAT_XTERM
xterm compatible color formatting.
public
mixed
FORMAT_XTERM
= 1
Properties
$_format
The color formatting being used.
protected
mixed
$_format
= self::FORMAT_NONE
One of the FORMAT_* constants.
Methods
__call()
Returns a colored version of $text, with the method name specifying the color:
public
__call(mixed $color, mixed $args) : string
echo $cliColor->lightred("Foo");
Parameters
- $color : mixed
- $args : mixed
Return values
string —The colored text.
__construct()
Constructor.
public
__construct([int $format = null ]) : mixed
Parameters
- $format : int = null
-
The color format to use. One of the FORMAT_* constants. Automatically detected by default.
Return values
mixed —background()
Returns a version of $text with a colored background.
public
background(string $color, string $text) : string
Parameters
- $color : string
-
The background color to use.
- $text : string
-
The text to print on this background.
Return values
string —The text with background.
bold()
Returns a bold version of $text.
public
bold(string $text) : string
Parameters
- $text : string
-
The text to bold.
Return values
string —The bolded text.
color()
Returns a colored version of $text.
public
color(string $color, string $text) : string
Parameters
- $color : string
-
The color to use. One of:
- normal
- black
- bold
- red
- green
- brown
- blue
- magenta
- cyan
- lightgray
- white
- darkgray
- lightred
- lightgreen
- yellow
- lightblue
- lightmagenta
- lightcyan
- $text : string
-
The text to print in this color.
Return values
string —The colored text.
format()
Returns a version of $text with a colored foreground and background.
public
format(string $foreground, string $background, string $text) : string
Parameters
- $foreground : string
-
The foreground color to use.
- $background : string
-
The background color to use.
- $text : string
-
The text to print in color.
Return values
string —The colored text.
remove()
Removes all color formatting from a text.
public
remove(string $text) : string
Parameters
- $text : string
-
A colored text.
Return values
string —The text with all coloring markup removed.
_backgroundColors()
Returns the xterm-compatible background color sequences.
protected
_backgroundColors() : array<string|int, mixed>
Return values
array<string|int, mixed> —Color sequences.
_foregroundColors()
Returns the xterm-compatible foreground color sequences.
protected
_foregroundColors() : array<string|int, mixed>
Return values
array<string|int, mixed> —Color sequences.