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

RenderTableDataTrait::renderEachCell()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 9.6666
cc 3
eloc 5
nc 3
nop 4
crap 3
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