Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
Code Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 2 | ||
Bugs | 1 | 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 |
||
18 | public function getConfigTreeBuilder() |
||
19 | { |
||
20 | $treeBuilder = new TreeBuilder(); |
||
21 | $rootNode = $treeBuilder->root('itkg_delay_event'); |
||
22 | $rootNode |
||
23 | ->fixXmlConfig('channel') |
||
24 | ->children() |
||
25 | ->scalarNode('command') |
||
26 | ->defaultValue('process dynamic command') |
||
27 | ->end() |
||
28 | ->arrayNode('mailer') |
||
29 | ->addDefaultsIfNotSet() |
||
30 | ->children() |
||
31 | ->scalarNode('from')->defaultValue('from')->end() |
||
32 | ->scalarNode('to')->defaultValue('to')->end() |
||
33 | ->scalarNode('subject')->defaultValue('subject')->end() |
||
34 | ->end() |
||
35 | ->end() |
||
36 | ->arrayNode('processor') |
||
37 | ->children() |
||
38 | ->arrayNode('retry_count') |
||
39 | ->children() |
||
40 | ->scalarNode('normal')->defaultValue(1)->end() |
||
41 | ->scalarNode('critic')->defaultValue(1)->end() |
||
42 | ->end() |
||
43 | ->end() |
||
44 | ->end() |
||
45 | ->end() |
||
46 | ->arrayNode('events') |
||
47 | ->prototype('array') |
||
48 | ->children() |
||
49 | ->enumNode('type') |
||
50 | ->values(['normal', 'critic']) |
||
51 | ->defaultValue('normal') |
||
52 | ->end() |
||
53 | ->end() |
||
54 | ->end() |
||
55 | ->end() |
||
56 | ->arrayNode('channels') |
||
57 | ->addDefaultChildrenIfNoneSet('default') |
||
58 | ->useAttributeAsKey('name') |
||
59 | ->prototype('array') |
||
60 | ->children() |
||
61 | ->booleanNode('dynamic') |
||
62 | ->defaultFalse() |
||
63 | ->end() |
||
64 | ->integerNode('events_limit_per_run') |
||
65 | ->defaultNull() |
||
66 | ->min(0) |
||
67 | ->end() |
||
68 | ->integerNode('duration_limit_per_run') |
||
69 | ->defaultNull() |
||
70 | ->min(0) |
||
71 | ->end() |
||
72 | ->arrayNode('include') |
||
73 | ->prototype('scalar')->end() |
||
74 | ->end() |
||
75 | ->arrayNode('exclude') |
||
76 | ->prototype('scalar')->end() |
||
77 | ->end() |
||
78 | ->end() |
||
79 | ->end() |
||
80 | ->end(); |
||
81 | |||
82 | return $treeBuilder; |
||
83 | } |
||
84 | } |
||
85 |