bc88e6d190ed7eec79daa36de0525687a9ef30eb
[yaffs-website] / vendor / consolidation / output-formatters / src / StructuredData / RowsOfFields.php
1 <?php
2 namespace Consolidation\OutputFormatters\StructuredData;
3
4 use Consolidation\OutputFormatters\Options\FormatterOptions;
5
6 /**
7  * Holds an array where each element of the array is one row,
8  * and each row contains an associative array where the keys
9  * are the field names, and the values are the field data.
10  *
11  * It is presumed that every row contains the same keys.
12  */
13 class RowsOfFields extends AbstractStructuredList
14 {
15     /**
16      * Restructure this data for output by converting it into a table
17      * transformation object.
18      *
19      * @param FormatterOptions $options Options that affect output formatting.
20      * @return Consolidation\OutputFormatters\Transformations\TableTransformation
21      */
22     public function restructure(FormatterOptions $options)
23     {
24         $data = $this->getArrayCopy();
25         return $this->createTableTransformation($data, $options);
26     }
27
28     public function getListData(FormatterOptions $options)
29     {
30         return array_keys($this->getArrayCopy());
31     }
32
33     protected function defaultOptions()
34     {
35         return [
36             FormatterOptions::LIST_ORIENTATION => false,
37         ] + parent::defaultOptions();
38     }
39 }