Format the received string parameters to be sent to the core get_string() function.

@param array $stringparams
@return object|string
@since Moodle 2.4
198033
public static function format_string_parameters($stringparams) {
        // Check if there are some string params.
        $strparams = new stdClass();
        if (!empty($stringparams)) {
            // There is only one string parameter.
            if (count($stringparams) == 1) {
                $stringparam = array_pop($stringparams);
                if (isset($stringparam['name'])) {
                    $strparams->{$stringparam['name']} = $stringparam['value'];
                } else {
                    // It is a not named string parameter.
                    $strparams = $stringparam['value'];
                }
            }  else {
                // There are more than one parameter.
                foreach ($stringparams as $stringparam) {

                    // If a parameter is unnamed throw an exception
                    // unnamed param is only possible if one only param is sent.
                    if (empty($stringparam['name'])) {
                        throw new moodle_exception('unnamedstringparam', 'webservice');
                    }

                    $strparams->{$stringparam['name']} = $stringparam['value'];
                }
            }
        }
        return $strparams;
    }
743129
@Override
	public String formatParams() {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < bindNames.size(); i++) {
			sb.append(String.format("[%s=%s]", bindNames.get(i), bindValiables.get(i)));
		}
		return sb.toString();
	}
663090
public function unserializeParams($params) {
		$parts = explode($this->options['param-delimiter'], $params);
		$params = [];
		foreach ($parts as $part) {
			$kv = explode('=', $part);
			if ($kv[0] != '') {
				$value = count($kv) > 1
					? $kv[1] == $this->options['param-true'] ? true
					: ($kv[1] == $this->options['param-false'] ? false : $kv[1]) : true;
				$params = $this->setParam($params, $kv[0], $value);
			}
		}
		
		return $params;
	}
870339
protected function formatKVLists(array $params)
    {
        $formatted = [];

        foreach ($params as $name => $value) {
            $formatted[] = [
                'key' => $name,
                'value' => strval($value),
            ];
        }

        return $formatted;
    }
1289588
private function parseParameters(array $parameters)
    {
        if (empty($parameters)) {
            return '';
        }

        $parameters = implode('&', array_map(
            function ($value, $key) {
                return sprintf('%s=%s', $key, urlencode($value));
            },
            $parameters,
            array_keys($parameters)
        ));

        return "&{$parameters}";
    }
301624
public static function maybe_split_parameters( $params ) {
		if ( ! \is_array( $params ) ) {
			// We can safely cast to an array here, as long as $params convertible to a string.
			$params = (array) \preg_split( self::RE_PARAMETER_SPLITTING, $params, -1, PREG_SPLIT_NO_EMPTY );
		}

		return $params;
	}
494894
private function GetParamString($param)
    {
        if ($param === null)
            return "null";
        if (is_string($param))
            return "'" .  addcslashes($param, "'") . "'";
        
        else if (is_bool($param))
            return $param ? "true" : "false";
        
        else if (is_int($param) || is_float($param))
            return (string)$param;
        
        else if ($param instanceof WritableClass)
            return $param->GetNewStatement();
        
        else if (is_array($param))
        {
            $resultArr = array();
            foreach ($param as $key=>$val)
            {
                $resultArr[] = $this->GetParamString($key) . '=>' . $this->GetParamString($val);
            }
            return 'array(' . join (', ' , $resultArr) .')';
        }
        else if ($param instanceof \Phine\Framework\System\Enum)
        {
            $value = $param->Value();
            $class = get_class($param);
            return "\\$class::ByValue('$value')";
        }
        throw new \InvalidArgumentException('A writable class must have primitive types, Enums, arrays and PhpWritable classes as construct params only.');
    }
1361383
private function buildQueryString(array $queryStringParams = null)
    {
        if ($queryStringParams === null) {
            return '';
        }

        $query = [];

        foreach ($queryStringParams as $key => $value) {
            $query[] = sprintf('%s=%s', $key, $value);
        }

        return sprintf('?%s', implode('&', $query));
    }
185493
public function strings($strings = null) {
		if (is_array($strings)) {
			return $this->_strings = $this->_strings + $strings;
		}
		if (is_string($strings)) {
			return isset($this->_strings[$strings]) ? $this->_strings[$strings] : null;
		}
		return $this->_strings;
	}
406921
protected function _toQuerystring($parameters) {
		$out = '';
		$keys = array_keys($parameters);
		$count = count($parameters);
		for ($i = 0; $i < $count; $i++) {
			$out .= $keys[$i] . '=' . $parameters[$keys[$i]];
			if ($i < $count - 1) {
				$out .= '&';
			}
		}
		return $out;
	}
797662
private function buildQueryString(array $params)
    {
        $flattened = [];
        foreach ($params as $key => $value) {
            $flattened[] = $key . '=' . $value;
        }
        $queryString = implode('&', $flattened);

        return $queryString;
    }
806472
protected function normalizeParams(array $params) {
		$processed = [];
		
		foreach ($params as $param => $value) {
			$processed[sprintf($this->paramsPattern, $param)] = $value;
		}
		
		return $processed;
	}
398034
public static function arrayFromGet($getParams)
        {
            $parts = explode('&', $getParams);

            if (static::is($parts)) {
                foreach ($parts as $part) {
                    $paramParts = explode('=', $part);

                    if (static::is($paramParts) && count($paramParts) == 2) {
                        $param[current($paramParts)] = end($paramParts);
                        unset($paramParts);
                    }
                }
            }

            return $param;
        }
1202675
public function parameterize( $params )
	{
		foreach( $params as $key => $param )
		{
			$params[$key] = $this->param( $param );
		}

		return implode( ', ', $params );
	}
514236
public function sprintf(string $string, ...$params): string
    {
        preg_match_all('/\:([A-Za-z0-9_]+)/', $string, $matches);
        $matches = $matches[1];

        if (count($matches)) {
            $tokens   = [];
            $replaces = [];

            foreach ($matches as $key => $value) {
                if (count($params) > 1 || !is_array($params[0])) {
                    if (!array_key_exists($key, $params)) {
                        throw new Exception('Too few arguments, missing argument: ' . $key);
                    }
                    $replaces[] = $params[$key];
                } else {
                    if (!array_key_exists($value, $params[0])) {
                        throw new Exception('Missing array argument: ' . $key);
                    }
                    $replaces[] = $params[0][$value];
                }
                $tokens[] = ':' . $value;
            }

            $string = str_replace($tokens, $replaces, $string);
        }

        return $string;
    }
599666
public function getCallable($params = [])
    {
        $className = $this->className;
        $methodName = $this->methodName;
        foreach($params as $name => $value)
        {
            $className = str_replace('{$' . $name . '}', $value, $className);
            $methodName = str_replace('{$' . $name . '}', $value, $methodName);
        }
        return [RequestContext::getServer()->getBean($className), $methodName];
    }
204239
protected function formatParameters(array $params)
    {
        $formatted = [];

        foreach ($params as $name => $value) {
            if (!in_array($name, ['member_count', 'room_limit', 'path', 'version_type'], true)) {
                continue;
            }

            if ('version_type' === $name && !in_array($value, ['develop', 'trial', 'release'], true)) {
                throw new InvalidArgumentException('Invalid value of attribute "version_type".');
            }

            $formatted[] = [
                'name' => $name,
                'value' => strval($value),
            ];
        }

        return $formatted;
    }