RenderTableDataTrait::renderEachCell()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

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