Completed
Push — 1.6 ( bb055d )
by Colin
01:28
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 MarkdownConverter
21
{
22
    /**
23
     * The currently-installed version.
24
     *
25
     * This might be a typical `x.y.z` version, or `x.y-dev`.
26
     *
27
     * @deprecated in 1.5.0 and will be removed from 2.0.0.
28
     *   Use \Composer\InstalledVersions provided by composer-runtime-api instead.
29
     */
30
    public const VERSION = '1.6-dev';
31
32
    /**
33
     * Create a new commonmark converter instance.
34
     *
35
     * @param array<string, mixed>      $config
36
     * @param EnvironmentInterface|null $environment
37
     */
38 2736
    public function __construct(array $config = [], EnvironmentInterface $environment = null)
39
    {
40 2736
        if ($environment === null) {
41 2130
            $environment = Environment::createCommonMarkEnvironment();
42
        } else {
43 606
            @\trigger_error(\sprintf('Passing an $environment into the "%s" constructor is deprecated in 1.6 and will not be supported in 2.0; use MarkdownConverter instead', self::class));
44
        }
45
46 2736
        if ($environment instanceof ConfigurableEnvironmentInterface) {
47 2736
            $environment->mergeConfig($config);
48
        }
49
50 2736
        parent::__construct($environment);
51 2736
    }
52
}
53