Conditions | 1 |
Paths | 1 |
Total Lines | 64 |
Code Lines | 60 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 1 |
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 |
||
25 | public function getTree() { |
||
26 | $treeBuilder = new \Symfony\Component\Config\Definition\Builder\TreeBuilder(); |
||
27 | $rootNode = $treeBuilder->root('phpmetrics'); |
||
28 | |||
29 | $rootNode |
||
30 | ->children() |
||
31 | ->arrayNode('rules') |
||
32 | ->useAttributeAsKey('rulename') |
||
33 | ->prototype('array') |
||
34 | ->children() |
||
35 | ->scalarNode('0')->end() |
||
36 | ->scalarNode('1')->end() |
||
37 | ->scalarNode('2')->end() |
||
38 | ->end() |
||
39 | ->end() |
||
40 | ->end() |
||
41 | ->scalarNode('failure') |
||
42 | ->defaultValue(null) |
||
43 | ->end() |
||
44 | ->arrayNode('path') |
||
45 | ->addDefaultsIfNotSet() |
||
46 | ->children() |
||
47 | ->scalarNode('directory')->defaultValue(null)->end() |
||
48 | ->scalarNode('exclude')->defaultValue('Tests|tests|Features|features|\.svn|\.git|vendor')->end() |
||
49 | ->scalarNode('extensions')->defaultValue('php|inc')->end() |
||
50 | ->booleanNode('symlinks')->defaultValue(false)->end() |
||
51 | ->end() |
||
52 | ->end() |
||
53 | ->booleanNode('ignore-errors')->defaultValue(false)->end() |
||
54 | ->arrayNode('logging') |
||
55 | ->addDefaultsIfNotSet() |
||
56 | ->children() |
||
57 | ->arrayNode('report') |
||
58 | ->children() |
||
59 | ->scalarNode('html')->defaultValue(null)->end() |
||
60 | ->scalarNode('xml')->defaultValue(null)->end() |
||
61 | ->scalarNode('csv')->defaultValue(null)->end() |
||
62 | ->scalarNode('json')->defaultValue(null)->end() |
||
63 | ->scalarNode('cli')->defaultValue(null)->end() |
||
64 | ->end() |
||
65 | ->end() |
||
66 | ->arrayNode('violations') |
||
67 | ->children() |
||
68 | ->scalarNode('xml')->defaultValue(null)->end() |
||
69 | ->end() |
||
70 | ->end() |
||
71 | ->arrayNode('chart') |
||
72 | ->children() |
||
73 | ->scalarNode('bubbles')->defaultValue(null)->end() |
||
74 | ->end() |
||
75 | ->end() |
||
76 | ->end() |
||
77 | ->end() |
||
78 | ->arrayNode('template') |
||
79 | ->addDefaultsIfNotSet() |
||
80 | ->children() |
||
81 | ->scalarNode('title')->defaultValue('PhpMetrics report') |
||
82 | ->end() |
||
83 | ->end() |
||
84 | ->end() |
||
85 | ; |
||
86 | |||
87 | return $treeBuilder->buildTree(); |
||
88 | } |
||
89 | } |