Return a formatted string. Modified version of sprintf using colon(:)

@param string $string
@param array  $params

@return String
@throws Exception
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;
    }
135775
private function apiGet($url, $params)
    {
        $url = $url . (strpos($url, '?') === false ? '?' : '') . http_build_query($params);

        try {
            $response = $this->httpClient->request('GET', $url, [
                'headers' => [
                    'user-key' => $this->igdbKey,
                    'Accept' => 'application/json'
                ]
            ]);
        } catch (RequestException $exception) {
            if ($response = $exception->getResponse()) {
                throw new \Exception($exception);
            }
            throw new \Exception($exception);
        } catch (Exception $exception) {
            throw new \Exception($exception);
        }

        return $response->getBody();
    }
953589
protected function getValueFromParameterString($name, $paramString, $value)
    {
        $original = $paramString;

        while (preg_match('@^(\[([^\]]+)\])@', $paramString, $matches)) {
            $key = $matches[2];
            $paramString = str_replace($matches[1], '', $paramString);

            if (!isset($value[$key])) {
                throw new Exception\ParameterKeyDoesNotExistException($name, $original);
            }

            $value = $value[$key];

            if (empty($paramString)) {
                break;
            }
        }

        return $value;
    }
1213606
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
    {
        $strlen = strlen($string);
        $ignoredChars = '';
        for ($i = 0; $i < $strlen; ++$i) {
            if ($string[$i] > "\x07F") {
                // Invalid char
                $currentMap[$i + $startOffset] = $string[$i];
            }
        }

        return $strlen;
    }
165707
public function writeIndented($string, $spaces = 2, $options = null) {
        return $this->write($this->indent($string, $spaces), $options);
    }
569465
public Parse getParse(String params) throws Exception {
    String action = "parse";
    Api api = getActionResult(action, params);
    super.handleError(api);
    return api.getParse();
  }
1033306
public function writeLineIndented($string, $spaces = 2, $options = null) {
        return $this->writeLine($this->indent($string, $spaces), $options);
    }
844969
public function call($method, array $params = array(), $format = 'php')
    {
        $params['method']       = $method;
        $params['token_auth']   = $this->token;
        $params['format']       = $format;

        $data = $this->getConnection()->send($params);

        if ('php' === $format) {
            $object = unserialize($data);

            if (isset($object['result']) && 'error' === $object['result']) {
                throw new Exception($object['message']);
            }

            return $object;
        } else {
            return $data;
        }
    }
819397
private static function formatParameters(array $params)
    {
        return '[' . implode(', ', array_map(static function ($param) {
            if (is_resource($param)) {
                return (string) $param;
            }

            $json = @json_encode($param);

            if (! is_string($json) || $json === 'null' && is_string($param)) {
                // JSON encoding failed, this is not a UTF-8 string.
                return sprintf('"%s"', preg_replace('/.{2}/', '\\x$0', bin2hex($param)));
            }

            return $json;
        }, $params)) . ']';
    }
970915
public static function key(string $key, array $params = []): string
    {
        $key = md5(serialize($key));
        if (count($params) > 0) {
            $key .= '-' . md5(serialize($params));
        }
        return $key;
    }
964225
public function translate($string) {

        // get selected signature

        if(empty($this->signature) === false) {
            if (array_key_exists($string, $this->signature) === false) {
                return $string;
            }
            return $this->signature[$string];
        }
        else {
            throw new Exception('Could not find translate signature');
        }
    }
767735
protected function escape(string $string): string
	{
		if($this->formatter !== null)
		{
			return $this->formatter->escape($string);
		}

		return $string;
	}
1252935
private function parseParameter(string $key, string $value, &$params): string
    {
        if (isset($params[$key])) {
            $par = $params[$key];
            unset($params[$key]);

            $value = $value ? $value . '_' . $par : $par;
        }

        return static::makeParam($key, $value);
    }
1081117
public function setString($string)
    {
        if (null === $string) {
            throw new Exception('The string cannot be null.');
        }

        $this->hash = md5($string);

        $this->convertHashToArrayOfBoolean();

        return $this;
    }
985033
protected function _replaceParameters($string, array $parameters = array())
    {
        //Adds curly braces around keys to make strtr work in replaceParameters method
        $replace_keys = function ($key) {
            return  '{'.$key.'}';
        };

        $keys       = array_map($replace_keys, array_keys($parameters));
        $parameters = array_combine($keys, $parameters);

        return strtr($string, $parameters);
    }
491848
public function renderStringTemplate(string $string, array $parameters = []): string
    {
        try {
            $parameters = iterator_to_array($this->getTemplateVariables($parameters));

            $environment = new Environment(new ArrayLoader());
            $template = $environment->createTemplate($string);

            return $environment->resolveTemplate($template)->render($parameters);
        } catch (Throwable $t) {
            return '';
        }
    }
340016
protected function getHeader(array $params)
	{
		// Prepare the function's header
		$header = "/**\n";
		foreach ($params as $paramName => $paramType)
		{
			$header .= '* @param {' . $paramType . '} ' . $paramName . "\n";
		}
		$header .= "*/\n";

		return $header;
	}