Completed
Push — master ( 69b698...47b727 )
by Greg
02:46
created

RenderTableDataTrait::renderData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 4
crap 2
1
<?php
2
namespace Consolidation\OutputFormatters\Formatters;
3
4
use Consolidation\OutputFormatters\StructuredData\RenderCellInterface;
5
6
trait RenderTableDataTrait
7
{
8
    /**
9
     * @inheritdoc
10
     */
11 13
    public function renderData($originalData, $restructuredData, $configurationData, $options)
12
    {
13 13
        if ($originalData instanceof RenderCellInterface) {
14 2
            return $this->renderEachCell($originalData, $restructuredData, $configurationData, $options);
15
        }
16 11
        return $restructuredData;
17
    }
18
19 2
    protected function renderEachCell($originalData, $restructuredData, $configurationData, $options)
20
    {
21 2
        foreach ($restructuredData as $id => $row) {
22 2
            foreach ($row as $key => $cellData) {
23 2
                $restructuredData[$id][$key] = $originalData->renderCell($key, $cellData, $configurationData, $options);
24 2
            }
25 2
        }
26 2
        return $restructuredData;
27
    }
28
}
29