private static function Inline::dumpArray

Dumps a PHP array to a YAML string.

Parameters

array $value The PHP array to dump:

Return value

string The YAML string representing the PHP array

1 call to Inline::dumpArray()
Inline::dump in drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php
Dumps a given PHP variable to a YAML string.

File

drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php, line 128

Class

Inline
Inline implements a YAML parser/dumper for the YAML inline syntax.

Namespace

Symfony\Component\Yaml

Code

private static function dumpArray($value) {

  // array
  $keys = array_keys($value);
  if (1 == count($keys) && '0' == $keys[0] || count($keys) > 1 && array_reduce($keys, function ($v, $w) {
    return (int) $v + $w;
  }, 0) == count($keys) * (count($keys) - 1) / 2) {
    $output = array();
    foreach ($value as $val) {
      $output[] = self::dump($val);
    }
    return sprintf('[%s]', implode(', ', $output));
  }

  // mapping
  $output = array();
  foreach ($value as $key => $val) {
    $output[] = sprintf('%s: %s', self::dump($key), self::dump($val));
  }
  return sprintf('{ %s }', implode(', ', $output));
}