IconBlockRenderer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 21
ccs 5
cts 9
cp 0.5556
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 11 2
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Davey Shafik <[email protected]>
7
 * (c) Colin O'Dell <[email protected]>
8
 * (c) Dan Hunsaker <[email protected]>
9
 *
10
 * Original code based on the CommonMark JS reference parser (http://bitly.com/commonmarkjs)
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 Danhunsaker\Markua\Block\Renderer;
18
19
use League\CommonMark\Block\Element\AbstractBlock;
20
use League\CommonMark\Block\Renderer\BlockRendererInterface;
21
use League\CommonMark\HtmlElement;
22
use League\CommonMark\ElementRendererInterface;
23
use Danhunsaker\Markua\Block\Element\IconBlock;
24
25
class IconBlockRenderer extends AsideRenderer implements BlockRendererInterface
26
{
27
    /**
28
     * @param AbstractBlock $block
29
     * @param ElementRendererInterface $htmlRenderer
30
     * @param bool $inTightList
31
     *
32
     * @return HtmlElement
33
     */
34 23
    public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
35
    {
36 23
        if (!($block instanceof IconBlock)) {
37
            throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
38
        }
39
40 23
        $htmlBlock = parent::render($block, $htmlRenderer, $inTightList);
41 23
        $htmlBlock->setAttribute('class', $block->getTypeName());
42
43 23
        return $htmlBlock;
44
    }
45
}
46