Back to ColorProcessor class

Method replaceColors

private mixed
replaceColors
(mixed $text, mixed $tag, mixed $match, \Joomla\CMS\Application\CLI\ColorStyle $style)
Replace color tags in a string.
Parameters
  • string $text The original text.
  • string $tag The matched tag.
  • string $match The match.
  • \Joomla\CMS\Application\CLI\ColorStyle $style The color style to apply.
Returns
  • mixed
Since
  • 4.0.0

Method replaceColors - Source code

/**
 * Replace color tags in a string.
 *
 * @param   string      $text   The original text.
 * @param   string      $tag    The matched tag.
 * @param   string      $match  The match.
 * @param   ColorStyle  $style  The color style to apply.
 *
 * @return  mixed
 *
 * @since   4.0.0
 */
private function replaceColors($text, $tag, $match, ColorStyle $style)
{
    $replace = $this->noColors ? $match : "\x1b[" . $style . 'm' . $match . "\x1b[0m";
    return str_replace('<' . $tag . '>' . $match . '</' . $tag . '>', $replace, $text);
}