CommonMarkCoreExtension   C
last analyzed

Coupling/Cohesion

Components 0
Dependencies 39

Complexity

Total Complexity 5

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 39
dl 0
loc 86
ccs 48
cts 48
cp 1
rs 5
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getInlineProcessors() 0 6 1
A getBlockParsers() 0 15 1
A getInlineParsers() 0 15 1
A getBlockRenderers() 0 15 1
A getInlineRenderers() 0 13 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 (https://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\Extension;
16
17
use League\CommonMark\Block\Parser as BlockParser;
18
use League\CommonMark\Block\Renderer as BlockRenderer;
19
use League\CommonMark\Inline\Parser as InlineParser;
20
use League\CommonMark\Inline\Processor as InlineProcessor;
21
use League\CommonMark\Inline\Renderer as InlineRenderer;
22
23
class CommonMarkCoreExtension extends Extension
24
{
25
    /**
26
     * @return BlockParser\BlockParserInterface[]
27
     */
28 1935
    public function getBlockParsers()
29
    {
30
        return [
31
            // This order is important
32 1935
            new BlockParser\BlockQuoteParser(),
33 1935
            new BlockParser\ATXHeadingParser(),
34 1935
            new BlockParser\FencedCodeParser(),
35 1935
            new BlockParser\HtmlBlockParser(),
36 1935
            new BlockParser\SetExtHeadingParser(),
37 1935
            new BlockParser\ThematicBreakParser(),
38 1935
            new BlockParser\ListParser(),
39 1935
            new BlockParser\IndentedCodeParser(),
40 1935
            new BlockParser\LazyParagraphParser(),
41 1935
        ];
42
    }
43
44
    /**
45
     * @return InlineParser\InlineParserInterface[]
46
     */
47 1935
    public function getInlineParsers()
48
    {
49
        return [
50 1935
            new InlineParser\NewlineParser(),
51 1935
            new InlineParser\BacktickParser(),
52 1935
            new InlineParser\EscapableParser(),
53 1935
            new InlineParser\EntityParser(),
54 1935
            new InlineParser\EmphasisParser(),
55 1935
            new InlineParser\AutolinkParser(),
56 1935
            new InlineParser\HtmlInlineParser(),
57 1935
            new InlineParser\CloseBracketParser(),
58 1935
            new InlineParser\OpenBracketParser(),
59 1935
            new InlineParser\BangParser(),
60 1935
        ];
61
    }
62
63
    /**
64
     * @return InlineProcessor\InlineProcessorInterface[]
65
     */
66 1935
    public function getInlineProcessors()
67
    {
68
        return [
69 1935
            new InlineProcessor\EmphasisProcessor(),
70 1935
        ];
71
    }
72
73
    /**
74
     * @return BlockRenderer\BlockRendererInterface[]
75
     */
76 1935
    public function getBlockRenderers()
77
    {
78
        return [
79 1935
            'League\CommonMark\Block\Element\BlockQuote'          => new BlockRenderer\BlockQuoteRenderer(),
80 1935
            'League\CommonMark\Block\Element\Document'            => new BlockRenderer\DocumentRenderer(),
81 1935
            'League\CommonMark\Block\Element\FencedCode'          => new BlockRenderer\FencedCodeRenderer(),
82 1935
            'League\CommonMark\Block\Element\Heading'             => new BlockRenderer\HeadingRenderer(),
83 1935
            'League\CommonMark\Block\Element\HtmlBlock'           => new BlockRenderer\HtmlBlockRenderer(),
84 1935
            'League\CommonMark\Block\Element\IndentedCode'        => new BlockRenderer\IndentedCodeRenderer(),
85 1935
            'League\CommonMark\Block\Element\ListBlock'           => new BlockRenderer\ListBlockRenderer(),
86 1935
            'League\CommonMark\Block\Element\ListItem'            => new BlockRenderer\ListItemRenderer(),
87 1935
            'League\CommonMark\Block\Element\Paragraph'           => new BlockRenderer\ParagraphRenderer(),
88 1935
            'League\CommonMark\Block\Element\ThematicBreak'       => new BlockRenderer\ThematicBreakRenderer(),
89 1935
        ];
90
    }
91
92
    /**
93
     * @return InlineRenderer\InlineRendererInterface[]
94
     */
95 1935
    public function getInlineRenderers()
96
    {
97
        return [
98 1935
            'League\CommonMark\Inline\Element\Code'       => new InlineRenderer\CodeRenderer(),
99 1935
            'League\CommonMark\Inline\Element\Emphasis'   => new InlineRenderer\EmphasisRenderer(),
100 1935
            'League\CommonMark\Inline\Element\HtmlInline' => new InlineRenderer\HtmlInlineRenderer(),
101 1935
            'League\CommonMark\Inline\Element\Image'      => new InlineRenderer\ImageRenderer(),
102 1935
            'League\CommonMark\Inline\Element\Link'       => new InlineRenderer\LinkRenderer(),
103 1935
            'League\CommonMark\Inline\Element\Newline'    => new InlineRenderer\NewlineRenderer(),
104 1935
            'League\CommonMark\Inline\Element\Strong'     => new InlineRenderer\StrongRenderer(),
105 1935
            'League\CommonMark\Inline\Element\Text'       => new InlineRenderer\TextRenderer(),
106 1935
        ];
107
    }
108
}
109