14 const BLACK =
'0;30',
DARK_GREY =
'1;30',
BLUE =
'0;34',
LIGHT_BLUE =
'1;34',
GREEN =
'0;32',
LIGHT_GREEN =
'1;32',
CYAN =
'0;36',
LIGHT_CYAN =
'1;36',
RED =
'0;31',
LIGHT_RED =
'1;31',
PURPLE =
'0;35',
LIGHT_PURPLE =
'1;35',
BROWN =
'0;33',
YELLOW =
'1;33',
LIGHT_GRAY =
'0;37',
WHITE =
'1;37';
28 public static function colorize($string, $color =
null, $bgColor =
null) {
29 if (! self::isSupported()) {
36 if (isset($bgColor)) {
40 return $coloredString;
44 $lines = explode(
"\n", $str);
45 array_walk($lines,
function (&$line) use ($prefix) {
46 if (trim($line) !=
null)
47 $line = $prefix . $line;
49 return implode(
"\n", $lines);
52 private static function escape($value) {
53 return "\033[{$value}m";
56 public static function showInfo($content, $dColor = self::CYAN) {
65 if (DIRECTORY_SEPARATOR ===
'\\') {
66 if (\function_exists(
'sapi_windows_vt100_support') && @sapi_windows_vt100_support(STDOUT)) {
68 } elseif (
'10.0.10586' === PHP_WINDOWS_VERSION_MAJOR .
'.' . PHP_WINDOWS_VERSION_MINOR .
'.' . PHP_WINDOWS_VERSION_BUILD ||
false !== \getenv(
'ANSICON') ||
'ON' === \getenv(
'ConEmuANSI') ||
'xterm' === \getenv(
'TERM')) {
73 return function_exists(
'posix_isatty') && @posix_isatty(STDOUT);
85 $content = str_replace(
"<br>",
"\n", $content);
87 $content = strip_tags($content);
99 public static function showMessage($content, $type =
'info', $title =
null) {
100 $header =
" ■ " . $type;
102 $header .=
' : ' . $title;
105 $content=wordwrap($content,$width-10);
121 $result = \rtrim($result,
"\n");
136 $reg =
'@<(b)>(.+?)</\1>@i';
137 if (! self::isSupported()) {
138 return \preg_replace($reg,
'$2', $str);
140 return \preg_replace($reg, self::escape(self::BOLD) .
'$2' . self::escape(self::END_BOLD), $str);