These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\FixturesBundle\DependencyInjection\Compiler; |
||
4 | |||
5 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
||
6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
7 | use Symfony\Component\DependencyInjection\Reference; |
||
8 | |||
9 | View Code Duplication | class PopulatorCompilerPass implements CompilerPassInterface |
|
0 ignored issues
–
show
|
|||
10 | { |
||
11 | /** |
||
12 | * @param ContainerBuilder $container |
||
13 | */ |
||
14 | 2 | public function process(ContainerBuilder $container) |
|
15 | { |
||
16 | 2 | if (!$container->hasDefinition('kunstmaan_fixtures.builder.builder')) { |
|
17 | 1 | return; |
|
18 | } |
||
19 | |||
20 | 1 | $definition = $container->getDefinition('kunstmaan_fixtures.populator.populator'); |
|
21 | 1 | $taggedServices = $container->findTaggedServiceIds('kunstmaan_fixtures.populator'); |
|
22 | |||
23 | 1 | foreach ($taggedServices as $id => $tagAttributes) { |
|
24 | 1 | foreach ($tagAttributes as $attributes) { |
|
25 | 1 | $definition->addMethodCall( |
|
26 | 1 | 'addPopulator', |
|
27 | 1 | [new Reference($id), $attributes['alias']] |
|
28 | ); |
||
29 | } |
||
30 | } |
||
31 | 1 | } |
|
32 | } |
||
33 |
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.