CommonMarkExtensionPass::process()   B
last analyzed

Complexity

Conditions 6
Paths 15

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 19
rs 8.8571
cc 6
eloc 10
nc 15
nop 1
1
<?php
2
3
/*
4
 * This is part of the webuni/commonmark-bundle package.
5
 *
6
 * (c) Martin Hasoň <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webuni\Bundle\CommonMarkBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
class CommonMarkExtensionPass implements CompilerPassInterface
19
{
20
    public function process(ContainerBuilder $container)
21
    {
22
        $extensions = [];
23
        foreach ($container->findTaggedServiceIds('webuni_commonmark.extension') as $id => $tag) {
24
            $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $id;
25
            $extensions[$alias] = $id;
26
        }
27
28
        if ($container->hasDefinition('webuni_commonmark.default_environment')) {
29
            $definition = $container->getDefinition('webuni_commonmark.default_environment');
30
            foreach ($extensions as $alias => $id) {
31
                $definition->addMethodCall('addExtension', [new Reference($id)]);
32
            }
33
        }
34
35
        foreach ($container->findTaggedServiceIds('webuni_commonmark.environment.extensions') as $id => $tag) {
0 ignored issues
show
Unused Code introduced by
This foreach statement is empty and can be removed.

This check looks for foreach loops that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

Consider removing the loop.

Loading history...
36
            // todo
37
        }
38
    }
39
}
40