Completed
Push — master ( 6c85d2...15e8d5 )
by Colin
04:57
created

HtmlInlineRenderer::render()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0417

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 5
cts 6
cp 0.8333
rs 9.4286
cc 3
eloc 6
nc 3
nop 2
crap 3.0417
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
7
 *
8
 * Original code based on the CommonMark JS reference parser (http://bitly.com/commonmark-js)
9
 *  - (c) John MacFarlane
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace League\CommonMark\Inline\Renderer;
16
17
use League\CommonMark\ElementRendererInterface;
18
use League\CommonMark\Inline\Element\AbstractInline;
19
use League\CommonMark\Inline\Element\HtmlInline;
20
use League\CommonMark\Util\Configuration;
21
use League\CommonMark\Util\ConfigurationAwareInterface;
22
23
class HtmlInlineRenderer implements InlineRendererInterface, ConfigurationAwareInterface
24
{
25
    /**
26
     * @var Configuration
27
     */
28
    protected $config;
29
30
    /**
31
     * @param HtmlInline               $inline
32
     * @param ElementRendererInterface $htmlRenderer
33
     *
34
     * @return string
35
     */
36 75
    public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
37
    {
38 75
        if (!($inline instanceof HtmlInline)) {
39 3
            throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
40
        }
41
42 72
        if ($this->config->getConfig('safe') === true) {
43
            return '';
44
        }
45
46 72
        return $inline->getContent();
47
    }
48
49
    /**
50
     * @param Configuration $configuration
51
     */
52 1878
    public function setConfiguration(Configuration $configuration)
53
    {
54 1878
        $this->config = $configuration;
55 1878
    }
56
}
57