protected function formatWithColor($color, $buffer)
{
if (!$this->colors) {
return $buffer;
}
$codes = array_map('trim', explode(',', $color));
$lines = explode("\n", $buffer);
$padding = max(array_map('strlen', $lines));
$styles = [];
foreach ($codes as $code) {
$styles[] = self::$ansiCodes[$code];
}
$style = sprintf("[%sm", implode(';', $styles));
$styledLines = [];
foreach ($lines as $line) {
$styledLines[] = $style . str_pad($line, $padding) . "[0m";
}
return implode("\n", $styledLines);
}
/** * @param string $color * @param string $buffer Result of the Test Case => . F S I R */ private function printTestCaseStatus($color, $buffer) { if ($this->column >= $this->maxNumberOfColumns) { $this->writeNewLine(); $padding = $this->maxClassNameLength; $this->column = $padding; echo str_pad(' ', $padding) . "\t"; } if ($this->isCIEnvironment()) { echo $buffer; $this->column++; return; } switch (strtoupper($buffer)) { case '.': $color = 'fg-green,bold'; $buffer = \mb_convert_encoding("'", 'UTF-8', 'UTF-16BE'); break; case 'F': $color = 'fg-red,bold'; $buffer = \mb_convert_encoding("'", 'UTF-8', 'UTF-16BE'); break; } echo parent::formatWithColor($color, $buffer); $this->column++; }