colorizeLines() public static method

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
return string
Example #1
0
 /**
  * Writes an error message to stderr
  *
  * @param \Exception $e
  * @return Console
  */
 public function writeException(\Exception $e)
 {
     if ($this->verboseException) {
         $text = sprintf("[%s]\n%s\nIn %s at line %s\n%s", get_class($e), $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
     } else {
         $text = sprintf("\n[%s]\n%s\n", get_class($e), $e->getMessage());
     }
     $box = new Widgets\Box($this->textWriter, $text, '');
     $out = Colors::colorizeLines($box, Colors::WHITE, Colors::RED);
     $out = TextFormater::apply($out, array('indent' => 2));
     $this->textWriter->writeln($out);
     return $this;
 }