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

HtmlInlineRenderer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 34
ccs 8
cts 9
cp 0.8889
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 12 3
A setConfiguration() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <coli[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