Format package name

@param array $vars

@return array
166283
public function inflectPackageVars($vars)
    {
        $restrictedWords = implode('|', array_keys($this->locations));

        $vars['name'] = strtolower($vars['name']);
        $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
            '$1',
            $vars['name']
        );

        return $vars;
    }
71750
public static function Format(string $query, ...$vars)
        {
            return preg_replace_callback(
                "~(%%?)(\d+)~i",
                function ($match) use (&$vars) {
                    $idx = $match[2] - 1;
                    if (!isset($vars[$idx])) {
                        return $match[0];
                    }

                    $val = &$vars[$match[2] - 1];

                    if ($match[1] === '%%') {
                        return "'{$val}'";
                    }
                    else if (is_null($val)) {
                        return "NULL";
                    }
                    else if (is_bool($val)) {
                        return $val ? 'true' : 'false';
                    }

                    return "'" . pg_escape_string($vars[$idx]) . "'";
                },
                $query
            );
        }
518128
public static function packFields(array $fields): string
    {
        $fmt = '';
        $args = [];

        // populate format string and argument list
        foreach ($fields as [$format, $value]) {
            if ($format === 'P') {
                $fmt .= 'VV';
                if ($value instanceof Bigint) {
                    $args[] = $value->getLow32();
                    $args[] = $value->getHigh32();
                } else {
                    $args[] = $value;
                    $args[] = 0;
                }
            } else {
                if ($value instanceof Bigint) {
                    $value = $value->getLow32();
                }
                $fmt .= $format;
                $args[] = $value;
            }
        }

        // prepend format string to argument list
        array_unshift($args, $fmt);

        // build output string from header and compressed data
        return pack(...$args);
    }
955385
protected static function formatParams($params)
    {
        $reslt = '';
        //
        for ($i = 0; $i < count($params); $i++) {
            $reslt .= '$'.$params[$i];
            if ($i < count($params) - 1) {
                $reslt .= ',';
            }
        }

        return $reslt;
    }
380904
public function formatValueList(array $list) {
		$string = '';
		foreach( $list as $i => $v ) {
			$string .= ($i ? ',' : '').$this->formatValue($v);
		}
		return $string;
	}
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)) . ']';
    }
576477
protected function buildJavaScriptSyntax(array $vars)
    {
        foreach ($vars as $key => $value) {
            $this->vars[] = $this->buildVariableInitialization($key, $value);
        }
    }
162302
public function returnFormField($vars)
    {
        extract($vars);
        $ret = '';
        if (isset($mask)) $ret .= '{' . $mask . '}';
        if (isset($preHtml)) { $ret .= $preHtml; }
        if (isset($html)) {
            $ret .= $html;
        } elseif (isset($items)) {
            foreach ($items as $i) {
                $ret .= $this->returnFormField($i);
            }
        } elseif (isset($component)) {
            $view = new Kwf_Component_Renderer();
            $ret .= $view->renderComponent($component);
        }
        if (isset($postHtml)) { $ret .= $postHtml; }
        if (isset($mask)) $ret .= '{/' . $mask . '}';
        return $ret;
    }
306848
public function loadVars(array $vars)
    {
        $this->vars = array_merge($this->vars, $vars);

        return (bool)empty($this->vars);
    }
1159811
private function translateChoices(array $vars): array
    {
        $domain = $vars['choice_translation_domain'];
        if ($domain === false)
            return $vars['choices'];
        if (empty($domain))
            $domain = $vars['translation_domain'];
        if ($domain === false)
            return $vars['choices'];
        if (empty($domain))
            $domain = $this->getTemplateManager()->getTranslationDomain();
        if ($domain === false)
            return $vars['choices'];

        foreach($vars['choices'] as $choice)
        {
            if (is_object($choice->data))
                return $vars['choices'];
            $choice->label = $this->getTranslator()->trans($choice->label, [], $domain);
        }

        return $vars['choices'];
    }
968139
public function itemsToFormat(array $items): string
    {
        return $this->strToCSV(array_map(function (Item $item) {
            return [
                $item->getId(),
                $item->getType(),
                json_encode($item->getMetadata()),
                json_encode($item->getIndexedMetadata()),
                json_encode($item->getSearchableMetadata()),
                json_encode($item->getExactMatchingMetadata()),
                json_encode($item->getSuggest()),
                json_encode(
                    ($item->getCoordinate() instanceof Coordinate)
                        ? $item->getCoordinate()->toArray()
                        : null
                ),
            ];
        }, $items));
    }
666031
public function inflectPackageVars($vars)
    {
        $vars['name'] = strtolower($vars['name']);
        $vars['name'] = preg_replace('/.ontowiki$/', '', $vars['name']);
        $vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
        $vars['name'] = preg_replace('/-translation$/', '', $vars['name']);

        return $vars;
    }
527736
public function render(array $vars = array())
    {
        $templateFile = $this->getTemplateRouter()->findTemplateFile($this->getRequest());
        if ($templateFile) {
            return $this->getAppController()->render($templateFile, $vars);
        }
        return $this->getAppController()->error404();
    }
981736
public static function getVariables($matches, &$vars = null)
    {
        if (!$matches) {
            return [];
        }

        if ($vars === null) {
            $vars = [];
        }

        foreach ($matches as $i => $var) {
            if (is_numeric($i)) {
                continue;
            }

            if (strpos((string) $var, '/') !== false) {
                $var = explode('/', (string) $var);
            }

            $vars[$i] = $var;
        }

        return $vars;
    }
311332
protected function getPackageReplacementTokens(PackageInterface $package)
    {
        $vars = array(
          '{$type}' => $package->getType(),
        );

        $prettyName = $package->getPrettyName();
        if (strpos($prettyName, '/') !== false) {
            $pieces = explode('/', $prettyName);
            $vars['{$vendor}'] = $pieces[0];
            $vars['{$name}'] = $pieces[1];

        } else {
            $vars['{$vendor}'] = '';
            $vars['{$name}'] = $prettyName;
        }

        return $vars;
    }
995567
public function parse(array $vars = [])
    {
        $this->loadVars($vars);

        $output = $this->parsePhp();

        // Run Template Engines
        $output = $this->template->parse($output, $this->vars);

        // Run String Engines
        $output = $this->string->parse($output, $this->vars);

        return $output;
    }
1037984
public function singular($key, array $vars = [])
    {
        if (isset(static::$strings[$key])) {
            $varKeys = array_keys($vars);
            foreach ($varKeys as $i => $k) {
                $varKeys[$i] = '{' . $k . '}';
            }

            return str_replace($varKeys, $vars, static::$strings[$key]);
        }

        return '';
    }