@@ -58,12 +58,6 @@ composer require jfcherng/php-color-output
5858 * @return string the string without colors
5959 */
6060\Jfcherng\Utility\CliColor::noColor(string $str): string
61-
62- // a global alias to \Jfcherng\Utility\CliColor::color()
63- function str_cli_color(string $str, $colors = [], bool $reset = true): string
64-
65- // a global alias to \Jfcherng\Utility\CliColor::noColor()
66- function str_cli_nocolor(string $str): string
6761```
6862
6963
@@ -74,26 +68,28 @@ function str_cli_nocolor(string $str): string
7468
7569include __DIR__ . '/vendor/autoload.php';
7670
71+ use \Jfcherng\Utility\CliColor;
72+
7773// colors in a string using a comma as the delimiter
78- echo str_cli_color ('foo', 'f_light_cyan, b_yellow'); // "\033[1;36;43mfoo\033[0m"
74+ echo CliColor::color ('foo', 'f_light_cyan, b_yellow'); // "\033[1;36;43mfoo\033[0m"
7975
8076echo PHP_EOL;
8177
8278// colors in an array
83- echo str_cli_color ('foo', ['f_white', 'b_magenta']); // "\033[1;37;45mfoo\033[0m"
79+ echo CliColor::color ('foo', ['f_white', 'b_magenta']); // "\033[1;37;45mfoo\033[0m"
8480
8581echo PHP_EOL;
8682
8783// do not auto reset color at the end of string
88- echo str_cli_color ('foo', ['f_red', 'b_green', 'b', 'blk'], false); // "\033[31;42;1;5mfoo"
84+ echo CliColor::color ('foo', ['f_red', 'b_green', 'b', 'blk'], false); // "\033[31;42;1;5mfoo"
8985
9086// manually add color reset
91- echo str_cli_color ('', 'reset'); // "\033[0m"
87+ echo CliColor::color ('', 'reset'); // "\033[0m"
9288
9389echo PHP_EOL;
9490
9591// remove all color codes from a string
96- echo str_cli_nocolor ("\033[31;42;5mfoo\033[0mbar"); // "foobar"
92+ echo CliColor::noColor ("\033[31;42;5mfoo\033[0mbar"); // "foobar"
9793
9894echo PHP_EOL;
9995```
0 commit comments