@param string $key
@param string|array $value

@return string
10889
private static function makeParam(string $key, $value): string
    {
        if (is_array($value)) {
            $tmp = [];
            foreach ($value as $v) {
                $tmp[] = urlencode((string)$key) . '[]=' . urlencode((string)$v);
            }

            return implode('&', $tmp);
        }

        return urlencode((string)$key) . '=' . urlencode((string)$value);
    }
200383
public static function where(string $key, string $value){

            return function($compare) use ($key, $value){

                return (@$compare[$key] == $value);

            };

        }
747872
protected function renderKeyValuePair($key, $value)
    {
        $output = [];
        $value = $this->normalizeValue($value);

        if (is_array($value)) {
            foreach ($value as $v) {
                $output[] = sprintf('%s[] = %s', $key, $v);
            }
        } else {
            $output[] = sprintf('%s = %s', $key, $value);
        }

        return $output;
    }
107535
private function parseRawToArray(&$value, &$key)
    {
        
        // parse a json string to an array
        if (is_string($value)) {
            
            $pos = substr($value,0,1);
            if ($pos == '[' || $pos == '(' || $pos == '{') {
                $json = json_decode($value);
            } else {
                $json = $value;
            }
            

            $pos = substr($value,0,1);
            if ($pos == '[' || $pos == '(' || $pos == '{') {
                $json = json_decode($value);
            } else {
                $json = $value;
            }
            
            if ($json) {                
                $value = $json;
            }
        }

        // if the value is an object, parse it to an array
        if (is_object($value)) {
            $value = (array)$value;
        }

        // call the recursive function to all keys of array
        if (is_array($value)) {
            array_walk_recursive($value, array($this, 'parseRawToArray'));
        }
  }
1065001
public function set($key, $value = null)
    {
        if (is_array($key)) {
            foreach ($key as $subkey => $value) {
                $this->set($subkey, $value);
            }
        } else {
            $this->parameters[$key] = $value;
        }
        return $this;
    }
131533
public function param($key, $value)
    {
        $this->params = array_merge($this->params ?? [], [$key => $value]);
        return $this;
    }
392626
protected function writeValue($key, $value) {
		$data = $this->readData();
		$data[$key] = $this->encode($value);

		if ($this->writeData($data)) {
			return $value;
		}

		return false;
	}
492292
private function parsePhpValue($key, $value, array &$result)
    {
        $node =& $result;
        $keyBuffer = '';

        for ($i = 0, $t = strlen($key); $i < $t; $i++) {
            switch ($key[$i]) {
                case '[':
                    if ($keyBuffer) {
                        $this->prepareNode($node, $keyBuffer);
                        $node =& $node[$keyBuffer];
                        $keyBuffer = '';
                    }
                    break;
                case ']':
                    $k = $this->cleanKey($node, $keyBuffer);
                    $this->prepareNode($node, $k);
                    $node =& $node[$k];
                    $keyBuffer = '';
                    break;
                default:
                    $keyBuffer .= $key[$i];
                    break;
            }
        }

        if (isset($node)) {
            $this->duplicates = true;
            $node[] = $value;
        } else {
            $node = $value;
        }
    }
774449
public function share($key, $value = null)
    {
        $keys = is_array($key) ? $key : [$key => $value];

        foreach ($keys as $key => $value) {
            $this->shared[$key] = $value;
        }

        return $value;
    }
1174514
private function escapeArray($value) {
        if (!is_array($value)) {
            return $this->escape($value);
        }
        foreach ($value as $key => $prop) {
            $value[$key] = $this->escape($prop);
        }
        return $value;
    }
534337
protected function checkValue($value, $key = null)
    {
        if ($value != null) {
            if ($key !== null) {
                return isset($value[$key]) ? $value[$key] : null;
            }

            return $value;
        }
    }
1296344
public function setData($key, $value = null)
    {
        if (is_array($key)) {
            foreach ($key as $key => $value) {
                if (!is_array($value) && !is_object($value)) {
                    $value = $this->stripInvalidUnicodeSequences(
                        $this->stringToUtf8(
                            $value,
                            ShopgateObject::$sourceEncodings
                        )
                    );
                }
                $this->$key = $value;
            }
        } else {
            if (!is_array($value) && !is_object($value)) {
                if (!is_null($value)) {
                    $value = $this->stripInvalidUnicodeSequences(
                        $this->stringToUtf8(
                            $value,
                            ShopgateObject::$sourceEncodings
                        )
                    );
                }
            }
            $this->$key = $value;
        }

        return $this;
    }
609948
protected function formatParam($key, $value)
    {
        $supportedFixes = [
            'lt'     => '<',
            'gt'     => '>',
            'lte'    => '<=',
            'gte'    => '>=',
            'lk'     => 'LIKE',
            'not-lk' => 'NOT LIKE',
            'in'     => 'IN',
            'not-in' => 'NOT IN',
            'not'    => '!=',
        ];

        $prefixes = implode('|', $supportedFixes);
        $suffixes = implode('|', array_keys($supportedFixes));

        $matches = [];

        // Matches every parameter with an optional prefix and/or postfix
        // e.g. not-title-lk, title-lk, not-title, title
        $regex = '/^(?:('.$prefixes.')-)?(.*?)(?:-('.$suffixes.')|$)/';

        preg_match($regex, $key, $matches);

        if (! isset($matches[3])) {
            if (Str::lower(trim($value)) == 'null') {
                $comparator = 'NULL';
            } else {
                $comparator = '=';
            }
        } else {
            if (Str::lower(trim($value)) == 'null') {
                $comparator = 'NOT NULL';
            } else {
                $comparator = $supportedFixes[$matches[3]];
            }
        }

        $column = isset($matches[2]) ? $matches[2] : null;

        return compact('comparator', 'column', 'matches');
    }
865134
protected static function extractKeyValueParameters($value, $key)
    {
        $value = is_string($value) ? explode('.', $value) : $value;
        $key   = is_null($key) || is_array($key) ? $key : explode('.', $key);

        return [$value, $key];
    }
1114133
protected function data($key, $value = false)
    {
        if (is_array($key)) {
            return $this->data = array_merge($this->data, $key);
        }

        return $this->data[$key] = $value;
    }
109178
public function setHeaders($key, $value = null)
    {
        if (is_array($key)) {
            foreach ($key as $a_key => $value) {
                $this->headers[strtolower($a_key)] = "$a_key: $value";
            }
        } elseif (empty($value)) {
            $this->headers[] = $key;
        } else {
            $this->headers[strtolower($key)] = "$key: $value";
        }

        return $this;
    }
199451
protected function getHtmlAttribValue($key, $value)
    {
        if (('on' == substr($key, 0, 2)) || ('constraints' == $key)) {
            // Don't escape event attributes; _do_ substitute double quotes with singles
            if (!is_scalar($value)) {
                // Non-scalar data should be cast to JSON first
                return Json::encode($value);
            }
            return $value;
        }
        
        if (is_array($value)) {
            return implode(' ', $value);
        }
        
        return $value;
    }