Conditions | 6 |
Paths | 18 |
Total Lines | 66 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
21 | public function load(array $configs, ContainerBuilder $container) |
||
22 | { |
||
23 | $configuration = new Configuration(); |
||
24 | $config = $this->processConfiguration($configuration, $configs); |
||
25 | |||
26 | $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
27 | $loader->load('services.xml'); |
||
28 | |||
29 | if (key_exists('codemirror', $config)) { |
||
30 | $loader->load('form.xml'); |
||
31 | |||
32 | |||
33 | |||
34 | if (key_exists('paths', $config['codemirror'])) { |
||
35 | $container |
||
36 | ->getDefinition('nvbooster_assets.twig_extension') |
||
37 | ->addArgument($config['codemirror']['paths']); |
||
38 | } |
||
39 | |||
40 | $container |
||
41 | ->getDefinition('nvbooster_assets.formtype.asset') |
||
42 | ->addArgument(array_merge( |
||
43 | array( |
||
44 | 'theme' => 'eclipse', |
||
45 | 'mode' => 'xml', |
||
46 | 'lineNumbers' => true |
||
47 | |||
48 | ), $config['codemirror']['options'] |
||
49 | )); |
||
50 | } |
||
51 | |||
52 | $bundles = $container->getParameter('kernel.bundles'); |
||
53 | if (isset($bundles['SonataAdminBundle'])) { |
||
54 | $loader->load('admin.xml'); |
||
55 | |||
56 | if (key_exists('codemirror', $config)) { |
||
57 | $container |
||
58 | ->getDefinition('nvbooster_assets.asset_admin') |
||
59 | ->addMethodCall('enableCodeMirror'); |
||
60 | $container |
||
61 | ->getDefinition('nvbooster_assets.js_asset_admin') |
||
62 | ->addMethodCall('enableCodeMirror'); |
||
63 | $container |
||
64 | ->getDefinition('nvbooster_assets.css_asset_admin') |
||
65 | ->addMethodCall('enableCodeMirror'); |
||
66 | } |
||
67 | } |
||
68 | |||
69 | $container |
||
70 | ->getDefinition('nvbooster_assets.routing.prefix_provider') |
||
71 | ->replaceArgument(0, $config['routing']['base_uri']); |
||
72 | |||
73 | if ($config['phpcr']['root_path']) { |
||
74 | $container->setParameter('nvbooster_assets.phpcr.root', $config['phpcr']['root_path']); |
||
75 | } |
||
76 | |||
77 | $root = $container->getParameter('nvbooster_assets.phpcr.root'); |
||
78 | |||
79 | $container |
||
80 | ->getDefinition('nvbooster_assets.phpcr.initializer') |
||
81 | ->addArgument(array($root)); |
||
82 | |||
83 | $container |
||
84 | ->getDefinition('nvbooster_assets.controller') |
||
85 | ->addArgument($config['filters']); |
||
86 | } |
||
87 | |||
114 |