public function toString($token)
    {
        $text = $token->token;
        static $prev;

        foreach ($this->options['formats'] as $format) {
            if ($token->type === $format['type']
                && ($token->flags & $format['flags']) === $format['flags']
            ) {
                // Running transformation function.
                if (! empty($format['function'])) {
                    $func = $format['function'];
                    $text = $func($text);
                }

                // Formatting HTML.
                if ($this->options['type'] === 'html') {
                    return '<span ' . $format['html'] . '>' . htmlspecialchars($text, ENT_NOQUOTES) . '</span>';
                } elseif ($this->options['type'] === 'cli') {
                    if ($prev !== $format['cli']) {
                        $prev = $format['cli'];

                        return $format['cli'] . $this->escapeConsole($text);
                    }

                    return $this->escapeConsole($text);
                }

                break;
            }
        }

        if ($this->options['type'] === 'cli') {
            if ($prev !== "\x1b[39m") {
                $prev = "\x1b[39m";

                return "\x1b[39m" . $this->escapeConsole($text);
            }

            return $this->escapeConsole($text);
        } elseif ($this->options['type'] === 'html') {
            return htmlspecialchars($text, ENT_NOQUOTES);
        }

        return $text;
    }
public function toString($token)
    {
        $text = $token->token;
        static $prev;

        foreach ($this->options['formats'] as $format) {
            if ($token->type === $format['type']
                && ($token->flags & $format['flags']) === $format['flags']
            ) {
                // Running transformation function.
                if (! empty($format['function'])) {
                    $func = $format['function'];
                    $text = $func($text);
                }

                // Formatting HTML.
                if ($this->options['type'] === 'html') {
                    return '<span ' . $format['html'] . '>' . htmlspecialchars($text, ENT_NOQUOTES) . '</span>';
                } elseif ($this->options['type'] === 'cli') {
                    if ($prev !== $format['cli']) {
                        $prev = $format['cli'];

                        return $format['cli'] . $this->escapeConsole($text);
                    }

                    return $this->escapeConsole($text);
                }

                break;
            }
        }

        if ($this->options['type'] === 'cli') {
            if ($prev !== "\x1b[39m") {
                $prev = "\x1b[39m";

                return "\x1b[39m" . $this->escapeConsole($text);
            }

            return $this->escapeConsole($text);
        } elseif ($this->options['type'] === 'html') {
            return htmlspecialchars($text, ENT_NOQUOTES);
        }

        return $text;
    }
public function toString ( $ token ) { $ text = $ token -> token ; static $ prev ; foreach ( $ this -> options [ 'formats' ] as $ format ) { if ( $ token -> type === $ format [ 'type' ] && ( $ token -> flags & $ format [ 'flags' ] ) === $ format [ 'flags' ] ) { // Running transformation function. if ( ! empty ( $ format [ 'function' ] ) ) { $ func = $ format [ 'function' ] ; $ text = $ func ( $ text ) ; } // Formatting HTML. if ( $ this -> options [ 'type' ] === 'html' ) { return '<span ' . $ format [ 'html' ] . '>' . htmlspecialchars ( $ text , ENT_NOQUOTES ) . '</span>' ; } elseif ( $ this -> options [ 'type' ] === 'cli' ) { if ( $ prev !== $ format [ 'cli' ] ) { $ prev = $ format [ 'cli' ] ; return $ format [ 'cli' ] . $ this -> escapeConsole ( $ text ) ; } return $ this -> escapeConsole ( $ text ) ; } break ; } } if ( $ this -> options [ 'type' ] === 'cli' ) { if ( $ prev !== "\x1b[39m" ) { $ prev = "\x1b[39m" ; return "\x1b[39m" . $ this -> escapeConsole ( $ text ) ; } return $ this -> escapeConsole ( $ text ) ; } elseif ( $ this -> options [ 'type' ] === 'html' ) { return htmlspecialchars ( $ text , ENT_NOQUOTES ) ; } return $ text ; }
Tries to print the query and returns the result.

@param Token $token the token to be printed

@return string
Tries to print the query and returns the result .