ClientCompilerPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 36.36%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 25
ccs 4
cts 11
cp 0.3636
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 20 4
1
<?php
2
3
namespace Freshcells\SoapClientBundle\DependencyInjection\CompilerPass;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class ClientCompilerPass implements CompilerPassInterface
10
{
11
    const CLIENT_TAG = 'freshcells_soap_client.client';
12
13 3
    public function process(ContainerBuilder $container)
14
    {
15 3
        $clients = $container->findTaggedServiceIds(self::CLIENT_TAG);
16
17 3
        foreach ($clients as $clientId => $tags) {
18
            if (count($tags) > 1) {
19
                throw new \LogicException(sprintf('Clients should use a single \'%s\' tag', self::CLIENT_TAG));
20
            }
21
22
            $clientDefinition = $container->findDefinition($clientId);
23
            if (isset($tags[0]['no_dispatcher']) === false) {
24
                $clientDefinition->addMethodCall(
25
                    'setDispatcher',
26
                    [
27
                        new Reference($container->getParameter('freshcells_soap_client.event_dispatcher.service'))
28
                    ]
29
                );
30
            }
31
        }
32 3
    }
33
}
34