RemoveUnavailableServicesPass   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 19 6
1
<?php
2
3
namespace Knp\RadBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
class RemoveUnavailableServicesPass implements CompilerPassInterface
9
{
10
    /**
11
     * {@inheritDoc}
12
     */
13
    public function process(ContainerBuilder $container)
14
    {
15
        foreach ($container->findTaggedServiceIds('remove-when-missing') as $id => $tags) {
16
            foreach ($tags as $tag) {
17
                if (!isset($tag['service'])) {
18
                    continue;
19
                }
20
21
                if ($container->hasDefinition($tag['service'])) {
22
                    continue;
23
                }
24
                if ($container->hasAlias($tag['service'])) {
25
                    continue;
26
                }
27
28
                $container->removeDefinition($id);
29
            }
30
        }
31
    }
32
}
33