Transformer::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of Platform package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Karma\Platform\Ast;
11
12
use Karma\Platform\Ast\Transformer\ParserInterface;
13
use Karma\Platform\Ast\Transformer\RendererInterface;
14
use Karma\Platform\Io\UserInterface;
15
16
/**
17
 * Class Transformer
18
 * @package Karma\Platform\Ast
19
 */
20
class Transformer implements RendererInterface, ParserInterface
21
{
22
    /**
23
     * @var RendererInterface
24
     */
25
    private $renderer;
26
27
    /**
28
     * @var ParserInterface
29
     */
30
    private $parser;
31
32
    /**
33
     * Transformer constructor.
34
     * @param RendererInterface $renderer
35
     * @param ParserInterface $parser
36
     */
37
    public function __construct(RendererInterface $renderer, ParserInterface $parser)
38
    {
39
        $this->renderer = $renderer;
40
        $this->parser = $parser;
41
    }
42
43
    /**
44
     * @param string $html
45
     * @param array|UserInterface[] $mentions
46
     * @return NodeList|NodeInterface[]
47
     */
48
    public function parse(string $html, array $mentions): NodeList
49
    {
50
        return $this->parser->parse($html, $mentions);
51
    }
52
53
    /**
54
     * @param NodeList $nodes
55
     * @return string
56
     */
57
    public function render(NodeList $nodes): string
58
    {
59
        return $this->renderer->render($nodes);
60
    }
61
62
}
63