Completed
Push — master ( 83739a...a13ee4 )
by Colin
14s queued 11s
created

SmartPunctExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 8
dl 0
loc 25
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 22 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\Extension\SmartPunct;
16
17
use League\CommonMark\Block\Element\Document;
18
use League\CommonMark\Block\Element\Paragraph;
19
use League\CommonMark\Block\Renderer as CoreBlockRenderer;
20
use League\CommonMark\ConfigurableEnvironmentInterface;
21
use League\CommonMark\Extension\ExtensionInterface;
22
use League\CommonMark\Inline\Element\Text;
23
use League\CommonMark\Inline\Renderer as CoreInlineRenderer;
24
25
class SmartPunctExtension implements ExtensionInterface
26
{
27 51
    public function register(ConfigurableEnvironmentInterface $environment)
28
    {
29
        $environment
30 51
            ->addInlineParser(new QuoteParser(), 10)
31 51
            ->addInlineParser(new PunctuationParser(), 0)
32
33 51
            ->addDelimiterProcessor(QuoteProcessor::createDoubleQuoteProcessor(
34 51
                $environment->getConfig('smartpunct/double_quote_opener', Quote::DOUBLE_QUOTE_OPENER),
35 51
                $environment->getConfig('smartpunct/double_quote_closer', Quote::DOUBLE_QUOTE_CLOSER)
36
            ))
37 51
            ->addDelimiterProcessor(QuoteProcessor::createSingleQuoteProcessor(
38 51
                $environment->getConfig('smartpunct/single_quote_opener', Quote::SINGLE_QUOTE_OPENER),
39 51
                $environment->getConfig('smartpunct/single_quote_closer', Quote::SINGLE_QUOTE_CLOSER)
40
            ))
41
42 51
            ->addBlockRenderer(Document::class, new CoreBlockRenderer\DocumentRenderer(), 0)
43 51
            ->addBlockRenderer(Paragraph::class, new CoreBlockRenderer\ParagraphRenderer(), 0)
44
45 51
            ->addInlineRenderer(Quote::class, new QuoteRenderer(), 100)
46 51
            ->addInlineRenderer(Text::class, new CoreInlineRenderer\TextRenderer(), 0)
47
        ;
48 51
    }
49
}
50