Conditions | 8 |
Paths | 28 |
Total Lines | 29 |
Lines | 5 |
Ratio | 17.24 % |
Changes | 0 |
1 | <?php |
||
15 | public function process(ContainerBuilder $container) |
||
16 | { |
||
17 | if (!$container->has('bruli.command.bus')) { |
||
18 | return; |
||
19 | } |
||
20 | |||
21 | $definition = $container->findDefinition('bruli.bus.options.resolver'); |
||
22 | $commandHandlers = $container->findTaggedServiceIds('bruli.command_handler'); |
||
23 | $preMiddleWares = $container->findTaggedServiceIds('bruli.command_pre_middleware'); |
||
24 | $postMiddleWares = $container->findTaggedServiceIds('bruli.command_post_middleware'); |
||
25 | |||
26 | View Code Duplication | foreach ($commandHandlers as $id => $tags) { |
|
|
|||
27 | foreach ($tags as $attributes) { |
||
28 | $definition->addMethodCall('addOption', [$attributes['handles'], $id]); |
||
29 | } |
||
30 | } |
||
31 | |||
32 | foreach ($preMiddleWares as $id => $tags) { |
||
33 | foreach ($tags as $attributes) { |
||
34 | $definition->addMethodCall('addPreMiddleWareOptions', [$attributes['handles'], $id]); |
||
35 | } |
||
36 | } |
||
37 | |||
38 | foreach ($postMiddleWares as $id => $tags) { |
||
39 | foreach ($tags as $attributes) { |
||
40 | $definition->addMethodCall('addPostMiddleWareOptions', [$attributes['handles'], $id]); |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 |
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.