Conditions | 1 |
Paths | 1 |
Total Lines | 55 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 2 |
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 |
||
27 | public function getConfigTreeBuilder() |
||
28 | { |
||
29 | $treeBuilder = new TreeBuilder(); |
||
30 | $rootNode = $treeBuilder->root('tadcka_routing'); |
||
31 | |||
32 | $rootNode |
||
33 | ->children() |
||
34 | ->scalarNode('db_driver')->cannotBeOverwritten()->isRequired()->end() |
||
35 | ->scalarNode('route_manager')->defaultValue('tadcka_routing.manager.route.default') |
||
36 | ->cannotBeEmpty()->end() |
||
37 | ->scalarNode('redirect_route_manager')->defaultValue('tadcka_routing.manager.redirect_route.default') |
||
38 | ->cannotBeEmpty()->end() |
||
39 | |||
40 | ->arrayNode('class')->isRequired() |
||
41 | ->children() |
||
42 | ->arrayNode('model')->isRequired() |
||
43 | ->children() |
||
44 | ->scalarNode('route')->isRequired()->end() |
||
45 | ->scalarNode('redirect_route')->isRequired()->end() |
||
46 | ->end() |
||
47 | ->end() |
||
48 | ->end() |
||
49 | ->end() |
||
50 | |||
51 | ->arrayNode('chain_router')->addDefaultsIfNotSet() |
||
52 | ->children() |
||
53 | ->booleanNode('enabled')->defaultFalse()->end() |
||
54 | ->end() |
||
55 | ->end() |
||
56 | |||
57 | ->arrayNode('dynamic_router')->addDefaultsIfNotSet() |
||
58 | ->children() |
||
59 | ->integerNode('priority')->defaultValue(0)->end() |
||
60 | ->end() |
||
61 | ->end() |
||
62 | |||
63 | ->arrayNode('router')->addDefaultsIfNotSet() |
||
64 | ->children() |
||
65 | ->integerNode('priority')->defaultValue(0)->end() |
||
66 | ->end() |
||
67 | ->end() |
||
68 | |||
69 | ->arrayNode('locales') |
||
70 | ->beforeNormalization() |
||
71 | ->ifString() |
||
72 | ->then(function($value) { return preg_split('/\s*,\s*/', $value); }) |
||
73 | ->end() |
||
74 | ->requiresAtLeastOneElement() |
||
75 | ->prototype('scalar')->end() |
||
76 | ->end() |
||
77 | |||
78 | ->end(); |
||
79 | |||
80 | return $treeBuilder; |
||
81 | } |
||
82 | } |
||
83 |