Skip to content

Commit cb7e181

Browse files
committed
📦 Simplify a bit collecting a name generators
1 parent a38eceb commit cb7e181

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/DependencyInjection/JaegerExtension.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,34 @@ public function load(array $configs, ContainerBuilder $container)
3333
$container->setParameter('jaeger.name.max_length', $config['name_generator']['max_length']);
3434
}
3535

36-
foreach ($config['name_generator']['request'] as $item => $customGeneratorId) {
37-
$regexp = \sprintf('/%s/', $item);
36+
foreach ($config['name_generator']['request'] as $pattern => $customGeneratorId) {
37+
$regexp = \sprintf('/%s/', $pattern);
38+
3839
$shortenedGeneratorId = \sprintf('jaeger.name.generator.%s', $customGeneratorId);
3940
if ($container->has($shortenedGeneratorId)) {
40-
$container->getDefinition('jaeger.name.generator.request')->addMethodCall(
41-
'add',
42-
[$regexp, new Reference($shortenedGeneratorId)]
43-
);
44-
} else {
45-
$container->getDefinition('jaeger.name.generator.request')->addMethodCall(
41+
$customGeneratorId = $shortenedGeneratorId;
42+
}
43+
44+
$container->getDefinition('jaeger.name.generator.request')
45+
->addMethodCall(
4646
'add',
4747
[$regexp, new Reference($customGeneratorId)]
4848
);
49-
}
5049
}
5150

5251
foreach ($config['name_generator']['command'] as $pattern => $customGeneratorId) {
5352
$regexp = \sprintf('/%s/', $pattern);
53+
5454
$shortenedGeneratorId = \sprintf('jaeger.name.generator.%s', $customGeneratorId);
5555
if ($container->has($shortenedGeneratorId)) {
56-
$container->getDefinition('jaeger.name.generator.command')->addMethodCall(
57-
'add',
58-
[$regexp, new Reference($shortenedGeneratorId)]
59-
);
60-
} else {
61-
$container->getDefinition('jaeger.name.generator.command')->addMethodCall(
56+
$customGeneratorId = $shortenedGeneratorId;
57+
}
58+
59+
$container->getDefinition('jaeger.name.generator.command')
60+
->addMethodCall(
6261
'add',
6362
[$regexp, new Reference($customGeneratorId)]
6463
);
65-
}
6664
}
6765
}
6866
}

0 commit comments

Comments
 (0)