2 namespace Consolidation\OutputFormatters\StructuredData;
4 use Consolidation\OutputFormatters\Options\FormatterOptions;
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.
11 * It is presumed that every row contains the same keys.
13 class RowsOfFields extends AbstractStructuredList implements ConversionInterface
18 public function convert(FormatterOptions $options)
20 $defaults = $this->defaultOptions();
21 $fields = $this->getFields($options, $defaults);
22 if (FieldProcessor::hasUnstructuredFieldAccess($fields)) {
23 return new UnstructuredListData($this->getArrayCopy());
29 * Restructure this data for output by converting it into a table
30 * transformation object.
32 * @param FormatterOptions $options Options that affect output formatting.
33 * @return Consolidation\OutputFormatters\Transformations\TableTransformation
35 public function restructure(FormatterOptions $options)
37 $data = $this->getArrayCopy();
38 return $this->createTableTransformation($data, $options);
41 public function getListData(FormatterOptions $options)
43 return array_keys($this->getArrayCopy());
46 protected function defaultOptions()
49 FormatterOptions::LIST_ORIENTATION => false,
50 ] + parent::defaultOptions();