2 namespace Consolidation\OutputFormatters\Formatters;
4 use Consolidation\OutputFormatters\Options\FormatterOptions;
5 use Consolidation\OutputFormatters\StructuredData\RenderCellInterface;
7 trait RenderTableDataTrait
12 public function renderData($originalData, $restructuredData, FormatterOptions $options)
14 if ($originalData instanceof RenderCellInterface) {
15 return $this->renderEachCell($originalData, $restructuredData, $options);
17 return $restructuredData;
20 protected function renderEachCell($originalData, $restructuredData, FormatterOptions $options)
22 foreach ($restructuredData as $id => $row) {
23 foreach ($row as $key => $cellData) {
24 $restructuredData[$id][$key] = $originalData->renderCell($key, $cellData, $options, $row);
27 return $restructuredData;