protected function _replaceTags($matches)
{
$style = $this->styles($matches['tag']);
if (empty($style)) {
return '<' . $matches['tag'] . '>' . $matches['text'] . '</' . $matches['tag'] . '>';
}
$styleInfo = [];
if (!empty($style['text']) && isset(static::$_foregroundColors[$style['text']])) {
$styleInfo[] = static::$_foregroundColors[$style['text']];
}
if (!empty($style['background']) && isset(static::$_backgroundColors[$style['background']])) {
$styleInfo[] = static::$_backgroundColors[$style['background']];
}
unset($style['text'], $style['background']);
foreach ($style as $option => $value) {
if ($value) {
$styleInfo[] = static::$_options[$option];
}
}
return "[" . implode($styleInfo, ';') . 'm' . $matches['text'] . "[0m";
}