Passed
Push — main ( 057518...00c1b7 )
by Colin
02:29 queued 26s
created

HtmlDecorator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 3 1
A __construct() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace League\CommonMark\Renderer;
15
16
use League\CommonMark\Node\Node;
17
use League\CommonMark\Util\HtmlElement;
18
19
final class HtmlDecorator implements NodeRendererInterface
20
{
21
    private NodeRendererInterface $inner;
22
    private string $tag;
23
    /** @var array<string, string|string[]|bool> */
24
    private array $attributes;
25
    private bool $selfClosing;
26
27
    /**
28
     * @param array<string, string|string[]|bool> $attributes
29
     */
30 4
    public function __construct(NodeRendererInterface $inner, string $tag, array $attributes = [], bool $selfClosing = false)
31
    {
32 4
        $this->inner       = $inner;
33 4
        $this->tag         = $tag;
34 4
        $this->attributes  = $attributes;
35 4
        $this->selfClosing = $selfClosing;
36 4
    }
37
38
    /**
39
     * {@inheritDoc}
40
     */
41 4
    public function render(Node $node, ChildNodeRendererInterface $childRenderer)
42
    {
43 4
        return new HtmlElement($this->tag, $this->attributes, $this->inner->render($node, $childRenderer), $this->selfClosing);
44
    }
45
}
46