Doctrine 1.2.4
sfYamlDumper Class Reference

Public Member Functions

 dump ($input, $inline=0, $indent=0)
 

Detailed Description

Definition at line 21 of file sfYamlDumper.php.

Member Function Documentation

sfYamlDumper::dump (   $input,
  $inline = 0,
  $indent = 0 
)

Dumps a PHP value to YAML.

Parameters
mixed$inputThe PHP value
integer$inlineThe level where you switch to inline YAML
integer$indentThe level o indentation indentation (used internally)
Returns
string The YAML representation of the PHP value

Definition at line 32 of file sfYamlDumper.php.

{
$output = '';
$prefix = $indent ? str_repeat(' ', $indent) : '';
if ($inline <= 0 || !is_array($input) || empty($input))
{
$output .= $prefix.sfYamlInline::dump($input);
}
else
{
$isAHash = array_keys($input) !== range(0, count($input) - 1);
foreach ($input as $key => $value)
{
$willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value);
$output .= sprintf('%s%s%s%s',
$prefix,
$isAHash ? sfYamlInline::dump($key).':' : '-',
$willBeInlined ? ' ' : "\n",
$this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + 2)
).($willBeInlined ? "\n" : '');
}
}
return $output;
}

The documentation for this class was generated from the following file: