CommonMarkConverter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 41
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 3
A getEnvironment() 0 4 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;
16
17
/**
18
 * Converts CommonMark-compatible Markdown to HTML.
19
 */
20
class CommonMarkConverter extends Converter
21
{
22
    /**
23
     * The currently-installed version.
24
     *
25
     * This might be a typical `x.y.z` version, or `x.y-dev`.
26
     */
27
    const VERSION = '0.19-dev';
28
29
    /** @var EnvironmentInterface */
30
    protected $environment;
31
32
    /**
33
     * Create a new commonmark converter instance.
34
     *
35
     * @param array                     $config
36
     * @param EnvironmentInterface|null $environment
37
     */
38 2037
    public function __construct(array $config = [], EnvironmentInterface $environment = null)
39
    {
40 2037
        if ($environment === null) {
41 2034
            $environment = Environment::createCommonMarkEnvironment();
42
        }
43
44 2037
        if ($environment instanceof ConfigurableEnvironmentInterface) {
45 2037
            $environment->mergeConfig($config);
46
        }
47
48 2037
        $this->environment = $environment;
49
50 2037
        parent::__construct(new DocParser($environment), new HtmlRenderer($environment));
51 2037
    }
52
53
    /**
54
     * @return EnvironmentInterface
55
     */
56 9
    public function getEnvironment(): EnvironmentInterface
57
    {
58 9
        return $this->environment;
59
    }
60
}
61