hhpack/color

Hack 的颜色包

1.3.0 2019-04-11 03:29 UTC

README

Latest Stable Version CircleCIDependency Status License

ScreenShot

基本用法

用户可以通过指定颜色输出到 stdout。

Color::fromColor(ForegroundColor::White)
    ->background(BackgroundColor::Green)
    ->println('%s succeeded.', 'Color package example');

或者

$color = Color::fromColor(ForegroundColor::White)
    ->background(BackgroundColor::Green);
$color('%s succeeded.', 'Color package example');

应用样式

用户可以使用 applyTo 方法将样式应用到文本上。

$text = Color::fromColor(ForegroundColor::White)
    ->background(BackgroundColor::Green)
    ->applyTo('target text');

echo $text;

文本的自定义样式

用户可以获取加粗和下划线。

Color::fromColor(ForegroundColor::White)
    ->addStyle(StyleType::Bold)
    ->addStyle(StyleType::Underlined)
    ->println('%s + %s', 'bold', 'underlined');

运行测试

您可以使用以下命令运行测试。

composer install
composer test