AutolinkExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 6 1
A configureSchema() 0 5 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\Autolink;
15
16
use League\CommonMark\Environment\EnvironmentBuilderInterface;
17
use League\CommonMark\Extension\ConfigurableExtensionInterface;
18
use League\Config\ConfigurationBuilderInterface;
19
use Nette\Schema\Expect;
20
21
final class AutolinkExtension implements ConfigurableExtensionInterface
22
{
23 194
    public function configureSchema(ConfigurationBuilderInterface $builder): void
24
    {
25 194
        $builder->addSchema('autolink', Expect::structure([
26 194
            'allowed_protocols' => Expect::listOf('string')->default(['http', 'https', 'ftp'])->mergeDefaults(false),
27 194
            'default_protocol' => Expect::string()->default('http'),
28 194
        ]));
29
    }
30
31 198
    public function register(EnvironmentBuilderInterface $environment): void
32
    {
33 198
        $environment->addInlineParser(new EmailAutolinkParser());
34 198
        $environment->addInlineParser(new UrlAutolinkParser(
35 198
            $environment->getConfiguration()->get('autolink.allowed_protocols'),
36 198
            $environment->getConfiguration()->get('autolink.default_protocol'),
37 198
        ));
38
    }
39
}
40