Completed
Push — master ( d37c6d...936e33 )
by Colin
23s queued 10s
created

CommonMarkConverter::getEnvironment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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