Exemplo n.º 1
0
Arquivo: Colors.php Projeto: ksst/kf
 /**
  * Colorizes a specific parts of a text, which are matched by search_regexp.
  *
  * @param string
  * @param string regexp
  * @param mixed|string|array
  * @param string $text
  * @param string $search_regexp
  * @param string $color
  */
 public static function colorizePart($text, $search_regexp, $color)
 {
     $callback = function ($matches) use($color) {
         return Colors::write($matches[1], $color);
     };
     $ansi_text = preg_replace_callback("/({$search_regexp})/", $callback, $text);
     return is_null($ansi_text) ? $text : $ansi_text;
 }