Conditions | 7 |
Paths | 9 |
Total Lines | 25 |
Code Lines | 12 |
Lines | 10 |
Ratio | 40 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public function process(ContainerBuilder $container) |
||
21 | { |
||
22 | if (!$container->has('domain_event.locator.named_event')) { |
||
23 | return; |
||
24 | } |
||
25 | |||
26 | $current_locator = $container->findDefinition('domain_event.locator'); |
||
27 | $named_event_locator = $container->findDefinition('domain_event.locator.named_event'); |
||
28 | |||
29 | // register services only if current locator is named event locator |
||
30 | if ($named_event_locator === $current_locator) { |
||
31 | View Code Duplication | foreach ($container->findTaggedServiceIds('domain_event.listener') as $id => $attributes) { |
|
|
|||
32 | foreach ($attributes as $attribute) { |
||
33 | $named_event_locator->addMethodCall('registerService', [$attribute['event'], $id]); |
||
34 | } |
||
35 | } |
||
36 | } |
||
37 | |||
38 | // BC: get services from old tag |
||
39 | View Code Duplication | foreach ($container->findTaggedServiceIds('domain_event.named_event_listener') as $id => $attributes) { |
|
40 | foreach ($attributes as $attribute) { |
||
41 | $named_event_locator->addMethodCall('registerService', [$attribute['event'], $id]); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | } |
||
46 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.