src/Decorator/Parser/Ansi.php
protected function replaceTag($str, $tag, &$history)
    {
        // We will be replacing tags one at a time, can't pass this by reference
        $replace_count = 1;

        if (strpos($tag, '/')) {
            // We are closing out the tag, pop off the last element and get the codes that are left
            array_pop($history);
            $replace = $this->end($history);
        } else {
            // We are starting a new tag, add it onto the history and replace with correct color code
            $history[] = $this->tags->value($tag);
            $replace = $this->start($this->tags->value($tag));
        }

        return str_replace($tag, $replace, $str, $replace_count);
    }
protected function replaceTag($str, $tag, &$history)
    {
        // We will be replacing tags one at a time, can't pass this by reference
        $replace_count = 1;

        if (strpos($tag, '/')) {
            // We are closing out the tag, pop off the last element and get the codes that are left
            array_pop($history);
            $replace = $this->end($history);
        } else {
            // We are starting a new tag, add it onto the history and replace with correct color code
            $history[] = $this->tags->value($tag);
            $replace = $this->start($this->tags->value($tag));
        }

        return str_replace($tag, $replace, $str, $replace_count);
    }
protected function replaceTag ( $ str , $ tag , & $ history ) { // We will be replacing tags one at a time, can't pass this by reference $ replace_count = 1 ; if ( strpos ( $ tag , '/' ) ) { // We are closing out the tag, pop off the last element and get the codes that are left array_pop ( $ history ) ; $ replace = $ this -> end ( $ history ) ; } else { // We are starting a new tag, add it onto the history and replace with correct color code $ history [ ] = $ this -> tags -> value ( $ tag ) ; $ replace = $ this -> start ( $ this -> tags -> value ( $ tag ) ) ; } return str_replace ( $ tag , $ replace , $ str , $ replace_count ) ; }
Replace the tag in the str

@param string $str
@param string $tag
@param array $history

@return string
Replace the tag in the str