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

HtmlInlineRenderer::setConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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