TableRenderer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 22
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This is part of the league/commonmark package.
7
 *
8
 * (c) Martin Hasoň <[email protected]>
9
 * (c) Webuni s.r.o. <[email protected]>
10
 * (c) Colin O'Dell <[email protected]>
11
 *
12
 * For the full copyright and license information, please view the LICENSE
13
 * file that was distributed with this source code.
14
 */
15
16
namespace League\CommonMark\Extension\Table;
17
18
use League\CommonMark\Node\Node;
19
use League\CommonMark\Renderer\ChildNodeRendererInterface;
20
use League\CommonMark\Renderer\NodeRendererInterface;
21
use League\CommonMark\Util\HtmlElement;
22
23
final class TableRenderer implements NodeRendererInterface
24
{
25
    /**
26
     * @param Table $node
27
     *
28
     * {@inheritdoc}
29
     *
30
     * @psalm-suppress MoreSpecificImplementedParamType
31
     */
32 84
    public function render(Node $node, ChildNodeRendererInterface $childRenderer)
33
    {
34 84
        if (! $node instanceof Table) {
35 3
            throw new \InvalidArgumentException('Incompatible node type: ' . \get_class($node));
36
        }
37
38 81
        $attrs = $node->data->get('attributes');
39
40 81
        $separator = $childRenderer->getInnerSeparator();
41
42 81
        $children = $childRenderer->renderNodes($node->children());
43
44 81
        return new HtmlElement('table', $attrs, $separator . \trim($children) . $separator);
45
    }
46
}
47