2 namespace Consolidation\OutputFormatters\Formatters;
4 use Symfony\Component\Yaml\Yaml;
5 use Consolidation\OutputFormatters\Options\FormatterOptions;
6 use Symfony\Component\Console\Output\OutputInterface;
11 * Convert an array or ArrayObject into Yaml.
13 class YamlFormatter implements FormatterInterface
18 public function write(OutputInterface $output, $data, FormatterOptions $options)
20 // Set Yaml\Dumper's default indentation for nested nodes/collections to
21 // 2 spaces for consistency with Drupal coding standards.
23 // The level where you switch to inline YAML is set to PHP_INT_MAX to
24 // ensure this does not occur.
25 $output->writeln(Yaml::dump($data, PHP_INT_MAX, $indent, false, true));