public function styleText($text)
    {
        if ($this->_outputAs == static::RAW) {
            return $text;
        }
        if ($this->_outputAs == static::PLAIN) {
            $tags = implode('|', array_keys(static::$_styles));

            return preg_replace('#</?(?:' . $tags . ')>#', '', $text);
        }

        return preg_replace_callback(
            '/<(?P<tag>[a-z0-9-_]+)>(?P<text>.*?)<\/(\1)>/ims',
            [$this, '_replaceTags'],
            $text
        );
    }
public function styleText($text)
    {
        if ($this->_outputAs == static::RAW) {
            return $text;
        }
        if ($this->_outputAs == static::PLAIN) {
            $tags = implode('|', array_keys(static::$_styles));

            return preg_replace('#</?(?:' . $tags . ')>#', '', $text);
        }

        return preg_replace_callback(
            '/<(?P<tag>[a-z0-9-_]+)>(?P<text>.*?)<\/(\1)>/ims',
            [$this, '_replaceTags'],
            $text
        );
    }
public function styleText ( $ text ) { if ( $ this -> _outputAs == static :: RAW ) { return $ text ; } if ( $ this -> _outputAs == static :: PLAIN ) { $ tags = implode ( '|' , array_keys ( static :: $ _styles ) ) ; return preg_replace ( '#</?(?:' . $ tags . ')>#' , '' , $ text ) ; } return preg_replace_callback ( '/<(?P<tag>[a-z0-9-_]+)>(?P<text>.*?)<\/(\1)>/ims' , [ $ this , '_replaceTags' ] , $ text ) ; }
Apply styling to text.

@param string $text Text with styling tags.
@return string String with color codes added.
Apply styling to text .