PHP Класс ConsoleKit\Colors

Text can be colorized (foreground only) by using a static method named after the color code. $text = Colors::colorize('hello world', Colors::RED) $text = Colors::colorize('hello world', 'red') $text = Colors::colorize('hello world', Colors::RED | Colors::BOLD) $text = Colors::colorize('hello world', 'red+bold') $text = Colors::red('hello world');
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__callStatic ( $method, $args )
colorize ( string $text, string $fgcolor = null, string $bgcolor = null ) : string Returns a colorized string
colorizeLines ( string $text, string $fgcolor = null, string $bgcolor = null ) : string Returns a text with each lines colorized independently
getBgColorString ( $colorCode ) : string Returns a background color string
getColorCode ( integer | string $color, array $options = [] ) : integer Returns a color code
getFgColorString ( $colorCode ) : string Returns a foreground color string

Приватные методы

Метод Описание
extractColorAndOptions ( integer $colorCode ) : array Extracts the options and the color from a color code

Описание методов

__callStatic() публичный статический Метод

public static __callStatic ( $method, $args )

colorize() публичный статический Метод

Returns a colorized string
public static colorize ( string $text, string $fgcolor = null, string $bgcolor = null ) : string
$text string
$fgcolor string (a key from the $foregroundColors array)
$bgcolor string (a key from the $backgroundColors array)
Результат string

colorizeLines() публичный статический Метод

Returns a text with each lines colorized independently
public static colorizeLines ( string $text, string $fgcolor = null, string $bgcolor = null ) : string
$text string
$fgcolor string
$bgcolor string
Результат string

getBgColorString() публичный статический Метод

Returns a background color string
public static getBgColorString ( $colorCode ) : string
Результат string

getColorCode() публичный статический Метод

$color can be a string with the color name, or one of the color constants.
public static getColorCode ( integer | string $color, array $options = [] ) : integer
$color integer | string
$options array
Результат integer

getFgColorString() публичный статический Метод

Returns a foreground color string
public static getFgColorString ( $colorCode ) : string
Результат string