*/ class ArrayDefinitionDumper implements DefinitionDumper { /** * {@inheritdoc} */ public function dump(Definition $definition) { if (! $definition instanceof ArrayDefinition) { throw new \InvalidArgumentException(sprintf( 'This definition dumper is only compatible with ArrayDefinition objects, %s given', get_class($definition) )); } $str = '[' . PHP_EOL; foreach ($definition->getValues() as $key => $value) { if (is_string($key)) { $key = "'" . $key . "'"; } $str .= ' ' . $key . ' => '; if ($value instanceof DefinitionHelper) { $nestedDefinition = Debug::dumpDefinition($value->getDefinition('')); $str .= $this->indent($nestedDefinition); } else { $str .= var_export($value, true); } $str .= ',' . PHP_EOL; } $str .= ']'; return $str; } private function indent($str) { return str_replace("\n", "\n ", $str); } }