Passed
Push — latest ( 3af091...d64e46 )
by Colin
03:49 queued 01:39
created

DescriptionListExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 7
c 1
b 0
f 0
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 10 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
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace League\CommonMark\Extension\DescriptionList;
15
16
use League\CommonMark\Environment\EnvironmentBuilderInterface;
17
use League\CommonMark\Event\DocumentParsedEvent;
18
use League\CommonMark\Extension\DescriptionList\Event\ConsecutiveDescriptionListMerger;
19
use League\CommonMark\Extension\DescriptionList\Event\LooseDescriptionHandler;
20
use League\CommonMark\Extension\DescriptionList\Node\Description;
21
use League\CommonMark\Extension\DescriptionList\Node\DescriptionList;
22
use League\CommonMark\Extension\DescriptionList\Node\DescriptionTerm;
23
use League\CommonMark\Extension\DescriptionList\Parser\DescriptionStartParser;
24
use League\CommonMark\Extension\DescriptionList\Renderer\DescriptionListRenderer;
25
use League\CommonMark\Extension\DescriptionList\Renderer\DescriptionRenderer;
26
use League\CommonMark\Extension\DescriptionList\Renderer\DescriptionTermRenderer;
27
use League\CommonMark\Extension\ExtensionInterface;
28
29
final class DescriptionListExtension implements ExtensionInterface
30
{
31 42
    public function register(EnvironmentBuilderInterface $environment): void
32
    {
33 42
        $environment->addBlockStartParser(new DescriptionStartParser());
34
35 42
        $environment->addEventListener(DocumentParsedEvent::class, new LooseDescriptionHandler(), 1001);
36 42
        $environment->addEventListener(DocumentParsedEvent::class, new ConsecutiveDescriptionListMerger(), 1000);
37
38 42
        $environment->addRenderer(DescriptionList::class, new DescriptionListRenderer());
39 42
        $environment->addRenderer(DescriptionTerm::class, new DescriptionTermRenderer());
40 42
        $environment->addRenderer(Description::class, new DescriptionRenderer());
41 42
    }
42
}
43