RenderTableDataTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderData() 0 7 2
A renderEachCell() 0 9 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