/** * @param $string * * @return string */ public function formatPlain($string) { $groups = $this->formatParser->parseFormat($string); foreach ($groups as $group) { $tag = $group[0]; $styleName = $group[1]; if ($styleName === 'style' || $this->hasStyle($styleName)) { $string = str_replace($tag, '', $string); } } $string = $this->formatParser->unescapeTags($string); return $string; }
/** * @param string $style * * @return IConsoleStyle */ public function parseStyle($style) { $groups = $this->formatParser->parseStyle($style); foreach ($groups as $group) { $type = $group[1]; $value = $group[2]; if (array_contains(['color', 'clr', 'fg'], $type)) { foreach (explode(',', $value) as $color) { $this->setColor($color); } } if (array_contains(['background', 'bg'], $type)) { foreach (explode(',', $value) as $background) { $this->setBackground($background); } } if (array_contains(['format', 'fmt'], $type)) { foreach (explode(',', $value) as $format) { $this->addFormat($format); } } } return $this; }