Wrap a value in keyword identifiers.

@param  Table|string  $value
@return string
341049
public function wrap($value)
		{
			// This method is primarily for convenience so we can just pass a
			// column or table instance into the wrap method without sending
			// in the name each time we need to wrap one of these objects.
			if ($value instanceof Table) {
				return $this->wrap_table($value->name);
			} elseif ($value instanceof Fluent) {
				$value = $value->name;
			}

			return parent::wrap($value);
		}
571902
public function mysqliStmtType($value) {
        $value = trim($value);
        if (!preg_match('/[^0-9\.]/', $value) && substr($value, 0, 1) != 0) {
            // d or i?
            return ctype_digit($value) ? 'i' : 'd';
        }
        return 's';
    }
1149212
private function wrapServiceConditionals($value, $code)
    {
        if (!$condition = $this->getServiceConditionals($value)) {
            return $code;
        }

        // re-indent the wrapped code
        $code = implode("\n", array_map(function ($line) { return $line ? '    '.$line : $line; }, explode("\n", $code)));

        return sprintf("        if (%s) {\n%s        }\n", $condition, $code);
    }
1248942
protected function wrapValue($value)
    {
        if ($value === '*') {
            return $value;
        }

        // If querying hstore
        if (preg_match('/\[(.*?)\]/', $value, $match)) {
            return (string)str_replace(array('[', ']'), '', $match[1]);
        }

        // If querying json column
        foreach ($this->jsonOperators as $operator) {
            if (stripos($value, $operator)) {
                list($value, $key) = explode($operator, $value, 2);
                return parent::wrapValue($value) . $operator . $key;
            }
        }

        return parent::wrapValue($value);
    }
673054
protected function encodeQuorum($value)
    {
        if (isset(self::$encode[$value])) {
            return self::$encode[$value];
        }

        return $value;
    }
605468
public function tokenize(string $value): string
    {
        $tokens = $this->tokenizer->tokenize($value);
        $tree = $this->buildTree($value, $tokens);

        $tokenizedValue = '';
        foreach ($tree as $node) {
            $tokenizedValue .= ($this->tokenizer->isOpeningToken($node))
                ? sprintf('<aliceTokenizedFunction(%s)>', $node)
                : $node
            ;
        }

        return $tokenizedValue;
    }
424245
static public function urlencode($value)
    {
        if (is_string($value)) {
            return urlencode($value);
        } elseif (is_array($value)) {
            foreach ($value as $k => $v) {
                $value[$k] = static::urlencode($v);
            }
        }
        return $value;
    }
29275
public function quote(?string $value): string
    {
        if ($value === null) {
            return 'NULL';
        }

        return $this->pdo->quote($value);
    }
825171
public static function describe($value): string
    {
        if (is_array($value)) {
            $value = '<array>';
        } elseif (is_object($value) || is_callable($value) || is_iterable($value)) {
            $value = sprintf('<%s>', get_class($value));
        } else {
            $value = (string)$value;
            if (strlen($value) > 30) {
                $value = substr($value, 0, -3) . '...';
            }
            $value = sprintf('"%s"', $value);
        }
        return $value;
    }
881602
public function encodeValue($value)
    {
        if ($this->urlEncode == self::RFC_3986) {
            return rawurlencode($value);
        } elseif ($this->urlEncode == self::FORM_URLENCODED) {
            return urlencode($value);
        } else {
            return (string) $value;
        }
    }
885176
public function addBindingValue(string $key, $value): string
    {
        $key = $this->removeTableFromKey($key);
        $placeholder = ':' . $key;
        if (!isset($this->bindingValues[$key])) {
            $this->bindingValues[$key] = $value;
            $this->bindingValueCounts[$key] = 1;
            return $placeholder;
        }

        $placeholder .= $this->bindingValueCounts[$key];
        $this->bindingValueCounts[$key]++;
        $this->bindingValues[$placeholder] = $value;
        return $placeholder;
    }
190413
private function checkForKeyword($value)
    {
        if (! isset($_SESSION['behat']['GenesisSqlExtension']['keywords'])) {
            return $value;
        }

        foreach ($_SESSION['behat']['GenesisSqlExtension']['keywords'] as $keyword => $val) {
            $key = sprintf('{%s}', $keyword);

            if ($value == $key) {
                $value = str_replace($key, $val, $value);
            }
        }

        return $value;
    }
345127
public function quote_table($value)
	{
		// Assign the table by reference from the value
		if (is_array($value))
		{
			$table =& $value[0];

			// Attach table prefix to alias
			$value[1] = $this->table_prefix().$value[1];
		}
		else
		{
			$table =& $value;
		}

		// deal with the sub-query objects first
		if ($table instanceof Database_Query)
		{
			// Create a sub-query
			$table = '('.$table->compile($this).')';
		}
		elseif (is_string($table))
		{
			if (strpos($table, '.') === false)
			{
				// Add the table prefix for tables
				$table = $this->quote_identifier($this->table_prefix().$table);
			}
			else
			{
				// Split the identifier into the individual parts
				$parts = explode('.', $table);

				if ($prefix = $this->table_prefix())
				{
					// Get the offset of the table name, 2nd-to-last part
					// This works for databases that can have 3 identifiers (Postgre)
					if (($offset = count($parts)) == 2)
					{
						$offset = 1;
					}
					else
					{
						$offset = $offset - 2;
					}

					// Add the table prefix to the table name
					$parts[$offset] = $prefix.$parts[$offset];
				}

				// Quote each of the parts
				$table = implode('.', array_map(array($this, 'quote_identifier'), $parts));
			}
		}

		// process the alias if present
		if (is_array($value))
		{
			// Separate the column and alias
			list ($value, $alias) = $value;

			return $value.' AS '.$this->quote_identifier($alias);
		}
		else
		{
			// return the value
			return $value;
		}
	}
370011
private function encodeQuery(string $value): string
    {
        return preg_replace_callback(
            '/(?:[^'.self::UNRESERVED.self::SUB_DELIMS.':@%~\/\[\]\?]+|%(?![A-Fa-f0-9]{2}))/',
            function (array $match) {
                return rawurlencode($match[0]);
            },
            $value
        );
    }
890953
protected static function _encodeValue($value)
    {
        $string = '';

        switch (gettype($value))
        {
            case 'integer':
            case 'double':
                $string = $value;
                break;

            case 'boolean':
                $string = $value ? 'true' : 'false';
                break;

            case 'string':
                // Sanitize any CRLF characters..
                $string = '"' . str_replace(array("\r\n", "\n"), '\\n', $value) . '"';
                break;
        }

        return $string;
    }
636271
private function stringEscaped($value)
    {
        $value = $this->string($value);
        $value = str_replace(self::$strReplaceFrom, self::$strReplaceTo, $value);

        return $value;
    }
1186297
private function decorateValue($value, $html = true) {
		if (is_string($value)) {
			if (trim($value) == '') {
				$decValue = '\'' . $value . '\'';
			} else {
				$decValue = htmlspecialchars($value);
			}
		} else if (is_bool($value)) {
			if ($value) $decValue = 'true';
			else $decValue = 'false';
			if ($html) {
				$decValue = '<strong>' . $decValue . '</strong>';
			}
		} else if (is_null($value)) {
			$decValue = 'null';
			if ($html){
				$decValue = '<strong><i>' . $decValue . '</i></strong>';
			}
		} else {
			$decValue = $value;
			if ($html) {
				$decValue = '<strong>' . $decValue . '</strong>';
			}
		}
		return $decValue;
	}