Conditions | 12 |
Paths | 19 |
Total Lines | 30 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
23 | public function process(ContainerBuilder $container): void |
||
24 | { |
||
25 | if (!$container->hasParameter('ekino.new_relic.monolog') || !$container->hasDefinition('monolog.logger')) { |
||
26 | return; |
||
27 | } |
||
28 | |||
29 | $configuration = $container->getParameter('ekino.new_relic.monolog'); |
||
30 | if ($container->hasDefinition('ekino.new_relic.logs_handler') && $container->hasParameter('ekino.new_relic.application_name')) { |
||
31 | $container->findDefinition('ekino.new_relic.logs_handler') |
||
32 | ->setArgument('$level', \is_int($configuration['level']) ? $configuration['level'] : \constant('Monolog\Logger::'.\strtoupper($configuration['level']))) |
||
33 | ->setArgument('$bubble', true) |
||
34 | ->setArgument('$appName', $container->getParameter('ekino.new_relic.application_name')); |
||
35 | } |
||
36 | |||
37 | if (!isset($configuration['channels'])) { |
||
38 | $channels = $this->getChannels($container); |
||
39 | } elseif ('inclusive' === $configuration['channels']['type']) { |
||
40 | $channels = $configuration['channels']['elements'] ?: $this->getChannels($container); |
||
41 | } else { |
||
42 | $channels = \array_diff($this->getChannels($container), $configuration['channels']['elements']); |
||
43 | } |
||
44 | |||
45 | foreach ($channels as $channel) { |
||
46 | try { |
||
47 | $def = $container->getDefinition('app' === $channel ? 'monolog.logger' : 'monolog.logger.'.$channel); |
||
48 | } catch (InvalidArgumentException $e) { |
||
49 | $msg = 'NewRelicBundle configuration error: The logging channel "'.$channel.'" does not exist.'; |
||
50 | throw new \InvalidArgumentException($msg, 0, $e); |
||
51 | } |
||
52 | $def->addMethodCall('pushHandler', [new Reference('ekino.new_relic.logs_handler')]); |
||
53 | } |
||
72 |