Version 1
[yaffs-website] / vendor / consolidation / output-formatters / src / Formatters / YamlFormatter.php
1 <?php
2 namespace Consolidation\OutputFormatters\Formatters;
3
4 use Symfony\Component\Yaml\Yaml;
5 use Consolidation\OutputFormatters\Options\FormatterOptions;
6 use Symfony\Component\Console\Output\OutputInterface;
7
8 /**
9  * Yaml formatter
10  *
11  * Convert an array or ArrayObject into Yaml.
12  */
13 class YamlFormatter implements FormatterInterface
14 {
15     /**
16      * @inheritdoc
17      */
18     public function write(OutputInterface $output, $data, FormatterOptions $options)
19     {
20         // Set Yaml\Dumper's default indentation for nested nodes/collections to
21         // 2 spaces for consistency with Drupal coding standards.
22         $indent = 2;
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));
26     }
27 }