Convert to string.

@param string $quote1 Quote compare1.
@param string $quote2 Quote compare2.

@return  string
350351
public function toString($quote1 = null, $quote2 = null)
    {
        if (is_callable($this->handler)) {
            return call_user_func_array(
                $this->handler,
                [$this->compare1, $this->compare2, $this->operator, $quote1, $quote2]
            );
        }

        $return = [];

        if ($this->compare1) {
            $return[] = $quote1 ? $this->quote($this->compare1, $quote1) : $this->compare1;
        }

        $return[] = $this->operator;

        if ($this->compare2) {
            $compare2 = $this->compare2;

            if (is_string($compare2)) {
                $compare2 = explode($this->separator, $this->compare2);
            }

            $self = $this;

            $compare2 = array_map(
                function ($value) use ($quote2, $self) {
                    return $self->quote($value, $quote2);
                },
                $compare2
            );

            $return[] = '(' . implode($this->separator, $compare2) . ')';
        }

        return implode(' ', $return);
    }
387165
public static function keyMatch($key1, $key2)
    {
        if (false === strpos($key2, '*')) {
            return $key1 == $key2;
        }

        $needle = rtrim($key2, '*');

        return substr($key1, 0, \strlen($needle)) === (string) $needle;
    }
133720
private function MatchQuoted($quote_char, $i){

		$matched = '';
		while( $i < $this->input_len ){
			$c = $this->input[$i];

			//escaped character
			if( $c === '\\' ){
				$matched .= $c . $this->input[$i+1];
				$i += 2;
				continue;
			}

			if( $c === $quote_char ){
				$this->pos = $i+1;
				$this->skipWhitespace(0);
				return $matched;
			}

			if( $c === "\r" || $c === "\n" ){
				return false;
			}

			$i++;
			$matched .= $c;
		}

		return false;
	}
458919
protected function unquoteString(&$quotedValue)
    {
        switch ($quotedValue[0]) {
            case '"':
                $quotedValue = str_replace('\\"', '"', trim($quotedValue, '"'));
                break;
            case '\'':
                $quotedValue = str_replace('\\\'', '\'', trim($quotedValue, '\''));
                break;
        }
        $quotedValue = str_replace('\\\\', '\\', $quotedValue);
    }
725505
public static function quoteFieldNames($fields)
    {
        $fieldArr = is_string($fields) ? explode(',', trim($fields)) : (array)$fields;
        
        foreach ($fieldArr as $k => $field) {
            $field = preg_replace("/(\s+)/", ' ', trim($field));
            if ($field == '*') {
                // do nothing
            } elseif (false !== strpos($field, '(')) {
                if (preg_match("/(.*?)\\((.*?)\\)(.*)/i", $field, $match)) {
                    // xx() | xx(xx) | xx(xx)xx
                    $field = $match[1] . '(' . QueryBuilder::quoteFieldName($match[2]).')' . QueryBuilder::quoteFieldName($match[3]);
                } else {
                    // xx( | xx(xx
                    $field = preg_replace_callback(
                        "/\\((.+)/i",
                        function($match) {
                            return '('.QueryBuilder::quoteFieldName($match[1]);
                        },
                        $field
                    );
                }

                $fieldArr[$k] = $field;
            } elseif (false !== strpos($field, ')')) {
                // xx)
                $field = preg_replace_callback(
                    "/(.*)\\)/i",
                    function($match) {
                        return QueryBuilder::quoteFieldName($match[1]) . ')';
                    },
                    $field
                );
                
                $fieldArr[$k] = QueryBuilder::quoteFieldName(substr($field, 0, strlen($field) - 1)) . ')';
            } else {
                $fieldArr[$k] = QueryBuilder::quoteFieldName($field);
            }
        }
        
        $rFields = implode(',', $fieldArr);        
        
        return $rFields;
    }
147458
public function generateReqIdFromQuoteTransfer(QuoteTransfer $quoteTransfer): string
    {
        return $this->generateReqId(
            $quoteTransfer->getTotals()->getHash(),
            $quoteTransfer->getCustomer()->getCustomerReference() ?? static::GUEST_CUSTOMER_REFERENCE
        );
    }
697298
public function toFixed($quote = false)
    {
        $txt = '';

        $this->_reformat(false, $quote);
        $lines = count($this->_output) - 1;
        foreach ($this->_output as $no => $line) {
            $txt .= $line['text'] . (($lines == $no) ? '' : "\n");
        }

        return $txt;
    }
482059
protected function commonStartString($string1, $string2)
    {
        $length = min(strlen($string1), strlen($string2));
        $common = '';
        for ($i = 0; $i < $length && $string1[$i] === $string2[$i]; ++$i) {
            $common .= $string1[$i];
        }

        return $common;
    }
246370
public function parseString($quote = '')
    {
        $token = $this->str[$this->last];
        if (! ($flags = Context::isString($token)) && $token !== $quote) {
            return null;
        }
        $quote = $token;

        while (++$this->last < $this->len) {
            if ($this->last + 1 < $this->len
                && (
                    ($this->str[$this->last] === $quote && $this->str[$this->last + 1] === $quote)
                    || ($this->str[$this->last] === '\\' && $quote !== '`')
                )
            ) {
                $token .= $this->str[$this->last] . $this->str[++$this->last];
            } else {
                if ($this->str[$this->last] === $quote) {
                    break;
                }
                $token .= $this->str[$this->last];
            }
        }

        if ($this->last >= $this->len || $this->str[$this->last] !== $quote) {
            $this->error(
                sprintf(
                    Translator::gettext('Ending quote %1$s was expected.'),
                    $quote
                ),
                '',
                $this->last
            );
        } else {
            $token .= $this->str[$this->last];
        }

        return new Token($token, Token::TYPE_STRING, $flags);
    }
41562
private function quoteValue($value)
    {
        if (is_numeric($value)) {
            return $value;
        }

        if ($value === null) {
            return 'null';
        }

        return $this->getConnection()->quote($value);
    }
517804
public function escapeStringValue($value, $quote = true)
    {
        $output = addcslashes((string)$value, "'");
        if ($quote === true) {
            $output = "'" . $output . "'";
        }

        return $output;
    }
661046
private function strcmpLowercaseFirst($str1, $str2)
	{
		$from = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
		$to = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		$inversedStr1 = strtr($str1, $from, $to);
		$inversedStr2 = strtr($str2, $from, $to);

		return strcmp($inversedStr1, $inversedStr2);
	}
1079640
public function quote($value)
    {
        if ($this->isDoubleQuoted()) {
            return $this->doubleQuote($value);
        } else {
            return $this->singleQuote($value);
        }
    }
481356
private function _quoteLiteral($literal)
    {
        if (is_numeric($literal) && !is_string($literal)) {
            return (string) $literal;
        } else if (is_bool($literal)) {
            return $literal ? "true" : "false";
        } else {
            return "'" . str_replace("'", "''", $literal) . "'";
        }
    }
430215
protected function quote($s, $start, $end)
    {
        if ($start == $end) {
            return "";
        }
        return preg_quote(substr($s, $start, $end), '#');
    }
735079
public function convertEq($expr1, $operator, $expr2)
	{
		$operator = $operator[0] . '=';
		if ($this->runner->getType($expr1) === 'String' && $this->runner->getType($expr2) === 'String')
		{
			$operator .= '=';
		}

		return $this->convertComparison($expr1, $operator, $expr2);
	}
212121
public static function stripOuterQuotes($value = "")
    {
        // if value passed as empty or is not a string then return false
        if (!$value) {
            return false;
        }

        /** @var string $cache Cache Value */
        $cache = self::cacheString($value);

        // check for cache
        if (isset(static::$stripOuterQuotesCache[$cache])) {
            return static::$stripOuterQuotesCache[$cache];
        }

        $start = (strlen($value) > 1 && self::startsWith($value, '"'))
            || (strlen($value) > 1 && self::startsWith($value, '\''));

        $end = (strlen($value) > 1 && self::endsWith($value, '"'))
            || (strlen($value) > 1 && self::endsWith($value, '\''));

        if ($start && $end) {
            return static::$stripOuterQuotesCache[$cache] = substr($value, 1, -1);
        }
        return static::$stripOuterQuotesCache[$cache] = $value;
    }