Test Setup Failed
Pull Request — latest (#3)
by Mark
65:38 queued 30:20
created

DocumentRenderer::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file was originally part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
11
 *  - (c) John MacFarlane
12
 *
13
 * For the full copyright and license information, please view the LICENSE
14
 * file that was distributed with this source code.
15
 */
16
17
namespace UnicornFail\Emoji\Renderer\Block;
18
19
use UnicornFail\Emoji\Node\Block\Document;
20
use UnicornFail\Emoji\Node\Node;
21
use UnicornFail\Emoji\Renderer\ChildNodeRendererInterface;
22
use UnicornFail\Emoji\Renderer\NodeRendererInterface;
23
24
final class DocumentRenderer implements NodeRendererInterface
25
{
26
    public function render(Node $node, ChildNodeRendererInterface $childRenderer): string
27
    {
28
        if (! ($node instanceof Document)) {
29
            throw new \InvalidArgumentException('Incompatible node type: ' . \get_class($node));
30
        }
31
32
        return $childRenderer->renderNodes($node->children());
33
    }
34
}
35