SmartPunctExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 15
c 1
b 0
f 0
dl 0
loc 23
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 21 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * Original code based on the CommonMark JS reference parser (http://bitly.com/commonmark-js)
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 League\CommonMark\Extension\SmartPunct;
18
19
use League\CommonMark\Environment\ConfigurableEnvironmentInterface;
20
use League\CommonMark\Extension\ExtensionInterface;
21
use League\CommonMark\Node\Block\Document;
22
use League\CommonMark\Node\Block\Paragraph;
23
use League\CommonMark\Node\Inline\Text;
24
use League\CommonMark\Renderer\Block as CoreBlockRenderer;
25
use League\CommonMark\Renderer\Inline as CoreInlineRenderer;
26
27
final class SmartPunctExtension implements ExtensionInterface
28
{
29 51
    public function register(ConfigurableEnvironmentInterface $environment): void
30
    {
31
        $environment
32 51
            ->addInlineParser(new QuoteParser(), 10)
33 51
            ->addInlineParser(new DashParser(), 0)
34 51
            ->addInlineParser(new EllipsesParser(), 0)
35
36 51
            ->addDelimiterProcessor(QuoteProcessor::createDoubleQuoteProcessor(
37 51
                $environment->getConfig('smartpunct/double_quote_opener', Quote::DOUBLE_QUOTE_OPENER),
38 51
                $environment->getConfig('smartpunct/double_quote_closer', Quote::DOUBLE_QUOTE_CLOSER)
39
            ))
40 51
            ->addDelimiterProcessor(QuoteProcessor::createSingleQuoteProcessor(
41 51
                $environment->getConfig('smartpunct/single_quote_opener', Quote::SINGLE_QUOTE_OPENER),
42 51
                $environment->getConfig('smartpunct/single_quote_closer', Quote::SINGLE_QUOTE_CLOSER)
43
            ))
44
45 51
            ->addRenderer(Document::class, new CoreBlockRenderer\DocumentRenderer(), 0)
46 51
            ->addRenderer(Paragraph::class, new CoreBlockRenderer\ParagraphRenderer(), 0)
47
48 51
            ->addRenderer(Quote::class, new QuoteRenderer(), 100)
49 51
            ->addRenderer(Text::class, new CoreInlineRenderer\TextRenderer(), 0);
50 51
    }
51
}
52