Completed
Push — master ( 9292e6...a84270 )
by Colin
03:12 queued 02:10
created

ChildRenderer::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\CommonMark\Extension\InlinesOnly;
13
14
use League\CommonMark\Node\Block\Document;
15
use League\CommonMark\Node\Node;
16
use League\CommonMark\Renderer\ChildNodeRendererInterface;
17
use League\CommonMark\Renderer\NodeRendererInterface;
18
19
/**
20
 * Simply renders child elements as-is, adding newlines as needed.
21
 */
22
final class ChildRenderer implements NodeRendererInterface
23
{
24
    /**
25
     * @param Node                       $node
26
     * @param ChildNodeRendererInterface $childRenderer
27
     *
28
     * @return string
29
     */
30 3
    public function render(Node $node, ChildNodeRendererInterface $childRenderer)
31
    {
32 3
        $out = $childRenderer->renderNodes($node->children());
33 3
        if (!$node instanceof Document) {
34 3
            $out .= $childRenderer->getBlockSeparator();
35
        }
36
37 3
        return $out;
38
    }
39
}
40