You are here

private static function Inline::dumpArray in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/symfony/yaml/Inline.php \Symfony\Component\Yaml\Inline::dumpArray()

Dumps a PHP array to a YAML string.

Parameters

array $value The PHP array to dump:

bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise:

bool $objectSupport true if object support is enabled, false otherwise:

Return value

string The YAML string representing the PHP array

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

File

vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php, line 179

Class

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

Namespace

Symfony\Component\Yaml

Code

private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport) {

  // array
  if ($value && !self::isHash($value)) {
    $output = array();
    foreach ($value as $val) {
      $output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport);
    }
    return sprintf('[%s]', implode(', ', $output));
  }

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