Return a formatted string
@param string|array $format
@param array $arguments
@param string $glue
@return string
16700
public function format($format, array $arguments = array(), $glue = '<br>')
    {
        if (is_array($format)) {
            $format = implode($glue, gplcart_array_flatten($format));
        }

        return vsprintf($format, $arguments);
    }
571007
private static function implodeSequential(string $glue, array $values)
    {
        $first_value = reset($values);
        $last_value = end($values);
        if ($first_value !== $last_value) {
            return $first_value . $glue . $last_value;
        }

        return $first_value;
    }
412904
public function _format($format, $placeholders = [], $default = '')
	{
		$placeholders = (array) $placeholders;
		$matches = [];
		if(!preg_match_all('/\{([^{}]*)\}+/u', $format, $matches))
			return sprintf($format, ...array_values($placeholders));

		ksort($placeholders, SORT_NATURAL);
		$placeholders['__default__'] = $default;
		$positions = array_flip(array_keys($placeholders));

		$type_specifiers = '/([sducoxXbgGeEfF])$/u';
		$replacements = [];

		foreach ($matches[1] as $match) {

			list($name, $options) = array_pad(explode(':', $match, 2), 2, '');
			if(!preg_match($type_specifiers, $options))
				$options .= 's';

			$position = array_key_exists($name, $positions)
			? $positions[$name]+1 : $positions['__default__']+1;

			$pattern = '%'.$position.'$'.$options;
			$replacements['{'.$match.'}'] = $pattern;
		}

		$format = str_replace(array_keys($replacements), array_values($replacements), $format);

		return sprintf($format, ...array_values($placeholders));
	}
406299
public function javascripts(string $collection, ?string $format = null) : string {
        return $this->serve($collection, 'javascripts', $format);
    }
571448
public function format($message, array $format)
    {
        $replace = [
            ':message' => $message,
            ':code' => $this->getStatusCode(),
        ];

        array_walk_recursive($format, function (&$value, $key) use ($replace) {
            if (isset($replace[$value])) {
                $value = $replace[$value];
            }
        });

        return $format;
    }
644149
public function prepareCommand(array $arguments = [])
    {
        $result = '';
        foreach ($arguments as $a) {
            $result .= ' ' . escapeshellarg($a);
        }

        return $result;
    }
1168437
public function formatString($string, $format) {

        $fmt = str_replace("_", "%s", $format);
        $str = str_split($string);

        return vsprintf($fmt, $str);
    }
1146823
public function byGlue(array $properties, string $glue, string $assGlue): string
    {
        if ($this->isNumeric($properties)) {
            return '';
        }

        $string = '';
        foreach ($properties as $key => $value) {
            if (!$value) {
                continue;
            }

            $string .= "{$key}{$assGlue}{$value}{$glue}";
        }
        $string = rtrim($string, $glue);

        return $string;
    }
867420
public function variantName($format, $arg = null)
    {
        $args = func_get_args();
        array_shift($args);
        return $format . Convert::base64url_encode($args);
    }
489850
private function replaceContext(string $format, array $context): string {
        $msg = preg_replace_callback('`({[^\s{}]+})`', function ($m) use ($context) {
            $field = trim($m[1], '{}');
            if (array_key_exists($field, $context)) {
                return $context[$field];
            } else {
                return $m[1];
            }
        }, $format);
        return $msg;
    }
745274
public function format($formatter, array $arguments = [])
    {
        $generator = $this->getGenerator();

        return function () use ($generator, $formatter, $arguments) {
            return $generator->format($formatter, $arguments);
        };
    }
83533
public static function string($value, $format = null)
    {
        if (is_null($format)) {
            $format = '%s';
        }

        return sprintf($format, $value);
    }
721339
public function toString($format='Json', array $options=[])
  {
    $handler = Format::getInstance($format);
    return $handler->objectToString($this->data, $options);
  }
574909
protected function applyFormat($format, $data)
    {

        foreach ($format as $key => $value) {
            $meta = array_values(array_filter($this->formatting, function ($item) use ($value) {
                return $item['name'] === $value['function'] ? true : false;
            }));

            if ($meta && !array_key_exists('class', $value)) {
                $data = $this->applyDefaultFormat($value, $meta[0], $data);
            } else {
                $data = $this->applyCustomFormat($value, $data);
            }
        }

        return $data;
    }
1364951
private function implodePregQuote($glue, array $pieces, $delimiter = null)
    {
        foreach ($pieces as &$p) {
            $p = preg_quote($p, $delimiter);
        }
        return implode($glue, $pieces);
    }
1036059
public static function loadString($data, $format = Format::JSON, $options = [])
    {
        // Load a string into the given namespace [or default namespace if not given]
        $class = static::getFormatClass($format);

        return $class::stringToStruct($data, $options);
    }
462831
public function format($format = null)
    {
        if (!$format) {
            $format = $this->getFormat();
        }

        return parent::format($format ?: static::$toStringFormat);
    }