Migrations\View\Helper\MigrationHelper::stringifyList PHP Method

stringifyList() public method

Returns an array converted into a formatted multiline string
public stringifyList ( array $list, array $options = [] ) : string
$list array array of items to be stringified
$options array options to use
return string
    public function stringifyList(array $list, array $options = [])
    {
        $options += ['indent' => 2];
        if (!$list) {
            return '';
        }
        ksort($list);
        foreach ($list as $k => &$v) {
            if (is_array($v)) {
                $v = $this->stringifyList($v, ['indent' => $options['indent'] + 1]);
                $v = sprintf('[%s]', $v);
            } else {
                $v = $this->value($v, $k === 'default');
            }
            if (!is_numeric($k)) {
                $v = "'{$k}' => {$v}";
            }
        }
        $start = $end = '';
        $join = ', ';
        if ($options['indent']) {
            $join = ',';
            $start = "\n" . str_repeat("    ", $options['indent']);
            $join .= $start;
            $end = "\n" . str_repeat("    ", $options['indent'] - 1);
        }
        return $start . implode($join, $list) . ',' . $end;
    }