Conditions | 15 |
Paths | 321 |
Total Lines | 68 |
Code Lines | 40 |
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 |
||
33 | public function process(ContainerBuilder $container): void |
||
34 | { |
||
35 | $parameters = $container->getParameterBag()->all(); |
||
36 | $definitions = $container->getDefinitions(); |
||
37 | $aliases = $container->getAliases(); |
||
38 | $exprLangProviders = $container->getExpressionLanguageProviders(); |
||
39 | $configAvailable = class_exists(BaseNode::class); |
||
40 | |||
41 | foreach ($container->getExtensions() as $extension) { |
||
42 | if ($extension instanceof PrependExtensionInterface) { |
||
43 | $extension->prepend($container); |
||
44 | } |
||
45 | } |
||
46 | |||
47 | foreach ($container->getExtensions() as $name => $extension) { |
||
48 | if (!$config = $container->getExtensionConfig($name)) { |
||
49 | // this extension was not called |
||
50 | continue; |
||
51 | } |
||
52 | $resolvingBag = $container->getParameterBag(); |
||
53 | if ($resolvingBag instanceof EnvPlaceholderParameterBag && $extension instanceof Extension) { |
||
54 | // create a dedicated bag so that we can track env vars per-extension |
||
55 | $resolvingBag = new MergeExtensionConfigurationParameterBag($resolvingBag); |
||
56 | if ($configAvailable) { |
||
57 | BaseNode::setPlaceholderUniquePrefix($resolvingBag->getEnvPlaceholderUniquePrefix()); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | try { |
||
62 | $config = $resolvingBag->resolveValue($config); |
||
63 | } catch (ParameterNotFoundException $e) { |
||
64 | $e->setSourceExtensionName($name); |
||
65 | |||
66 | throw $e; |
||
67 | } |
||
68 | |||
69 | try { |
||
70 | $tmpContainer = new MergeExtensionConfigurationContainerBuilder($extension, $resolvingBag); |
||
71 | $tmpContainer->setResourceTracking($container->isTrackingResources()); |
||
72 | $tmpContainer->addObjectResource($extension); |
||
73 | if ($extension instanceof ConfigurationExtensionInterface && null !== $configuration = $extension->getConfiguration($config, $tmpContainer)) { |
||
74 | $tmpContainer->addObjectResource($configuration); |
||
75 | } |
||
76 | |||
77 | foreach ($exprLangProviders as $provider) { |
||
78 | $tmpContainer->addExpressionLanguageProvider($provider); |
||
79 | } |
||
80 | |||
81 | $extension->load($config, $tmpContainer); |
||
82 | } catch (\Exception $e) { |
||
83 | if ($resolvingBag instanceof MergeExtensionConfigurationParameterBag) { |
||
84 | $container->getParameterBag()->mergeEnvPlaceholders($resolvingBag); |
||
|
|||
85 | } |
||
86 | |||
87 | throw $e; |
||
88 | } |
||
89 | |||
90 | if ($resolvingBag instanceof MergeExtensionConfigurationParameterBag) { |
||
91 | // don't keep track of env vars that are *overridden* when configs are merged |
||
92 | $resolvingBag->freezeAfterProcessing($extension, $tmpContainer); |
||
93 | } |
||
94 | |||
95 | $container->merge($tmpContainer); |
||
96 | $container->getParameterBag()->add($parameters); |
||
97 | } |
||
98 | |||
99 | $container->addDefinitions($definitions); |
||
100 | $container->addAliases($aliases); |
||
101 | } |
||
213 |