UrlProviderCompilerPass   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 22
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 20 6
1
<?php
2
3
namespace LAG\SmokerBundle\DependencyInjection\CompilerPass;
4
5
use LAG\SmokerBundle\Contracts\Url\Provider\UrlProviderInterface;
6
use LAG\SmokerBundle\Url\Registry\UrlProviderRegistry;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
class UrlProviderCompilerPass implements CompilerPassInterface
12
{
13 2
    public function process(ContainerBuilder $container)
14
    {
15 2
        if (!$container->hasDefinition(UrlProviderRegistry::class)) {
16 1
            return;
17
        }
18 1
        $registry = $container->getDefinition(UrlProviderRegistry::class);
19
20 1
        foreach ($container->getDefinitions() as $serviceId => $definition) {
21 1
            if (null === $definition->getClass()) {
22 1
                continue;
23
            }
24
25 1
            if (!class_exists($definition->getClass())) {
26 1
                continue;
27
            }
28 1
            $implements = class_implements($definition->getClass());
29
30 1
            if (in_array(UrlProviderInterface::class, $implements)) {
31 1
                $registry->addMethodCall('add', [
32 1
                    new Reference($serviceId),
33
                ]);
34
            }
35
        }
36 1
    }
37
}
38