Passed
Push — main ( 16e3d2...2668c7 )
by Damien
07:42
created

TableCellExporter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DH\Adf\Exporter\Html\Child;
6
7
use DH\Adf\Exporter\Html\HtmlExporter;
8
use DH\Adf\Node\Child\TableCell;
9
10
class TableCellExporter extends HtmlExporter
11
{
12
    public function __construct(TableCell $node)
13
    {
14
        parent::__construct($node);
15
16
        $attributes = [];
17
        if (null !== $node->getBackground()) {
18
            $attributes[] = sprintf('style="background-color: %s"', $node->getBackground());
19
        }
20
        if (null !== $node->getColspan()) {
21
            $attributes[] = sprintf('colspan="%s"', $node->getColspan());
22
        }
23
        if (null !== $node->getRowspan()) {
24
            $attributes[] = sprintf('rowspan="%s"', $node->getRowspan());
25
        }
26
        // TODO: support colwidth
27
28
        $this->tags = [
29
            sprintf('<td%s>', implode(' ', $attributes)),
30
            '</td>',
31
        ];
32
    }
33
}
34