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

TableCellExporter::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 11
c 1
b 0
f 0
nc 8
nop 1
dl 0
loc 19
rs 9.9
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