Format args array.

@param array  $data
@param string $name

@return string
542332
protected static function arrayFormat(array $data, $name)
    {
        $format = "\t'$name' => [\n";

        if (count($data) > 0) {
            foreach ($data as $key => $value) {
                $format .= "\t\t'$key' => $value::class , \n";
            }
        } else {
            $format .= "\t\t//\n";
        }

        $format .= "\t],\n\n";

        return $format;
    }
1254583
public static function make($name, $data = []): string
    {
        $view = new static($name, $data);

        DebugBar::addView($name, $data);

        return $view->render();
    }
691261
public static function createFromArray($name, array $data = [])
    {
        $type = parent::createFromArray($name, $data);
        \assert($type instanceof self);

        $type->json = $data;

        return $type;
    }
109515
public function render($name, array $data = [])
    {
        if (strpos($name, '.php')!==false) {
            return (new PhpTemplate($this))->render($name, $data);
        } else {
            return (new TwigTemplate($this))->render($name, $data);
        }
        
        throw new LogicException(sprintf("Template type '%s' not recognized", $name));
    }
680012
public function getUri(string $name, array $data = [], $warnData = true) : Uri
    {
        if (!isset($this->routes[$name])) {
            throw new \InvalidArgumentException(sprintf("Invalid route name '%s'", $name));
        }

        $route = $this->routes[$name];

        $uri = self::request()->getUri();
        $uri->removeAllQueries()
            ->setFragment(null)
            ->setPath($this->routeRegexp($route, $data))
        ;

        // $cloneData = $data;

        // append querystring
        if ($route->getUserInputs()) {
            $queryToAdd = [];
            foreach ($route->getUserInputs() as $querystring) {
                if (!isset($data[$querystring->getName()]) &&
                    $querystring->isMandatory() &&
                    $warnData &&
                    $route->getHttpMethod() != 'POST' &&
                    $route->getHttpMethod() != 'PUT' &&
                    $route->getHttpMethod() != 'DELETE'
                ) {
                    throw new \InvalidArgumentException(sprintf(
                        "Missing querystring '%s' to generate route '%s'",
                        $querystring->getName(),
                        $route->getName()
                    ));
                }

                if (isset($data[$querystring->getName()])) {
                    // unset($cloneData[$querystring->getName()]);
                    $queryToAdd[$querystring->getName()] = $data[$querystring->getName()];
                }
            }

            $uri->addQueries($queryToAdd);
        }

        /*
        // Args can be consumed by routeRegexp and not remove from cloneData
        if (sizeof($cloneData)) {
            throw new \InvalidArgumentException(sprintf(
                "Too many data to generate route '%s' with keys %s",
                $route->getName(),
                "'" . implode("', '", array_keys($cloneData)) . "'"
            ));
        }
        */

        return $uri;
    }
194693
public function commands($name, $data = array())
    {
        $toolbar = $this->_template->getHelper('controller')->getToolbar();

        if (isset($data['clone'])) {
            $toolbar = clone $toolbar;
        }

        if ($toolbar instanceof AnControllerToolbarAbstract) {
            //reset the toolbar
            $toolbar->reset();

            $method = 'add'.ucfirst($name).'Commands';

            if (method_exists($toolbar, $method)) {
                $toolbar->$method();
            }

            return $toolbar->getCommands();
        }
    }
997945
public function make($name, array $data = [], $format = null)
    {
        return new Facile($this, $name, $data, $format);
    }
1314969
protected function renderHtml($name = null, $data = []) {
        if (is_array($name)) {
            $data = $name;
            $name = null;
        }
        return $this->renderFile($this->getViewFile($name), $data);
    }
645897
public function layout($name, array $data = [])
    {
        $this->layoutName = $name;
        $this->layoutData = $data;
        $this->engine->getProject()->get('file_layout_cache')->merge([$this->file->getUid() => [$this->layoutName]]);
    }
1244829
public function attr($name, $args = [])
    {
        $attr = $this->hasMapping($name) ? $this->getMapping($name) : $name;
        
        if (func_num_args() > 1) {
            return $this->prefix(vsprintf($attr, (array) $args));
        }
        
        return $this->prefix($attr);
    }
1215786
public function __callData(string $name, array $args)
    {
        //if the method starts with get
        if (strpos($name, 'get') === 0) {
            //getUserName('-')
            $separator = '_';
            if (isset($args[0]) && is_scalar($args[0])) {
                $separator = (string) $args[0];
            }

            $key = preg_replace("/([A-Z0-9])/", $separator."$1", $name);
            //get rid of get
            $key = strtolower(substr($key, 3 + strlen($separator)));

            return $this->__getData($key);
        } else if (strpos($name, 'set') === 0) {
            //setUserName('Chris', '-')
            $separator = '_';
            if (isset($args[1]) && is_scalar($args[1])) {
                $separator = (string) $args[1];
            }

            $key = preg_replace("/([A-Z0-9])/", $separator."$1", $name);

            //get rid of set
            $key = strtolower(substr($key, 3 + strlen($separator)));

            $this->__setData($key, isset($args[0]) ? $args[0] : null);

            return $this;
        }

        throw DataException::forMethodNotFound(get_class($this), $name);
    }
1202281
private function formatCapabilities(array $data): array
    {
        $result = [];
        foreach ($data as $controller => $list) {
            $newList = [];
            foreach ($list as $type => $caps) {
                foreach ($caps as $cap) {
                    $field = $cap->getField();
                    $key = !empty($field) ? "${type}_(_${field}_)" : $type;
                    $newList[$key][] = $cap;
                }
            }
            $result[$controller] = $newList;
        }

        return $result;
    }
1348578
protected function cutArgument($name, &$args)
    {
        if (isset($args[$name])) {
            $result = $args[$name];
            unset($args[$name]);
            return $result;
        }

        return null;
    }
1329458
public function format($name, array $data) {
        if (!isset($this->_compiled[$name])) {
            throw new RuntimeException("Cannot find template named '$name'.");
        }
        list($template, $placeholders) = $this->_compiled[$name];
        // If there is a {{attrs.xxxx}} block in $template, remove the xxxx attribute
        // from $data['attrs'] and add its content to $data['attrs.class'].
        if (isset($data['attrs'])) {
            foreach ($placeholders as $placeholder) {
                if (substr($placeholder, 0, 6) == 'attrs.'
                    && preg_match('#'.substr($placeholder, 6).'="([^"]*)"#',
                                  $data['attrs'], $matches) > 0) {
                    $data['attrs'] = preg_replace('#'.substr($placeholder, 6).'="[^"]*"#',
                                                  '', $data['attrs']);
                    $data[$placeholder] = trim($matches[1]);
                    if ($data[$placeholder]) {
                        $data[$placeholder] = ' '.$data[$placeholder];
                    }
                }
            }
            $data['attrs'] = trim($data['attrs']);
            if ($data['attrs']) {
                $data['attrs'] = ' '.$data['attrs'];
            }
        }
        return parent::format($name, $data);
    }
574098
protected static function _formatCalledArgument($arg)
        {
            $out = '';
            if (is_object($arg)) {
                $out .= sprintf("&%s#%s#", get_class($arg), spl_object_hash($arg));

            } else if (is_resource($arg)) {
                $out .= '#[' . get_resource_type($arg) . ']';
            } else if (Arrays::isArray($arg)) {
                $isAssociative = false;
                $args = array();
                foreach ($arg as $k => $v) {
                    if (!is_numeric($k)) {
                        $isAssociative = true;
                    }
                    $args[$k] = static::_formatCalledArgument($v);
                }
                if ($isAssociative) {
                    $arr = array();
                    foreach ($args as $k => $v) {
                        $arr[] = static::_formatCalledArgument($k) . ' => ' . $v;
                    }
                    $out .= 'array(' . join(', ', $arr) . ')';
                } else {
                    $out .= 'array(' . join(', ', $args) . ')';
                }
            } else if (is_null($arg)) {
                $out .= 'NULL';
            } else if (is_numeric($arg) || is_float($arg)) {
                $out .= $arg;
            } else if (is_string($arg)) {
                if (strlen($arg) > static::$argLength) {
                    $arg = substr($arg, 0, static::$argLength) . "...";
                }
                $arg = strtr($arg, array("\t" => '\t', "\r" => '\r', "\n" => '\n', "'" => '\\\''));
                $out .= "'" . $arg . "'";
            } else if (is_bool($arg)) {
                $out .= $arg === true ? 'true' : 'false';
            }

            return $out;
        }
1070804
public function formatArgs(array $args)
    {
        $result = [];
        foreach ($args as $key => $item) {
            if ('object' === $item[0]) {
                $parts = explode('\\', $item[1]);
                $short = array_pop($parts);
                $formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
            } elseif ('array' === $item[0]) {
                $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
            } elseif ('string' === $item[0]) {
                $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
            } elseif ('null' === $item[0]) {
                $formattedValue = '<em>null</em>';
            } elseif ('boolean' === $item[0]) {
                $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
            } elseif ('resource' === $item[0]) {
                $formattedValue = '<em>resource</em>';
            } else {
                $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true));
            }

            $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
        }

        return implode(', ', $result);
    }
352672
public static function buildFeature($name, array $data = array())
    {
        $values = [];

        $value = null;
        if (isset($data['values'])) {
            foreach ($data['values'] as $value) {

                $filter = $isFeature = null;
                if (isset($value['filters']) && !empty($value['filters'])) {
                    $filter = self::buildFilterBag($value['filters']);
                }
                if (isset($value['is_feature'])) {
                    $isFeature = (bool) $value['is_feature'];
                }

                $values[] = new Value($value['value'], $filter, $isFeature);
            }
            $value = new ValueBag($values);
        }

        $filter = null;
        if (isset($data['filters']) && !empty($data['filters'])) {
            $filter = self::buildFilterBag($data['filters']);
        }

        $breaker = null;
        if (isset($data['breaker']) && !empty($data['breaker'])) {
            $breaker = self::buildFilterBag($data['breaker']);
        }

        $feature = new Feature($name, $filter, $breaker, $value);

        if (isset($data['enabled']) && !$data['enabled']) {
            $feature->setEnabled(false);
        }

        return $feature;
    }