Conditions | 1 |
Paths | 1 |
Total Lines | 90 |
Code Lines | 86 |
Lines | 0 |
Ratio | 0 % |
Tests | 85 |
CRAP Score | 1 |
Changes | 6 | ||
Bugs | 0 | Features | 4 |
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 |
||
19 | 42 | public function getConfigTreeBuilder() |
|
20 | { |
||
21 | 42 | $treeBuilder = new TreeBuilder(); |
|
22 | 42 | $rootNode = $treeBuilder->root('innmind_provisioner'); |
|
23 | |||
24 | $rootNode |
||
25 | 42 | ->children() |
|
26 | 42 | ->arrayNode('threshold') |
|
27 | 42 | ->children() |
|
28 | 42 | ->arrayNode('cpu') |
|
29 | 42 | ->children() |
|
30 | 42 | ->integerNode('max') |
|
31 | 42 | ->defaultValue(100) |
|
32 | 42 | ->min(0) |
|
33 | 42 | ->end() |
|
34 | 42 | ->integerNode('min') |
|
35 | 42 | ->defaultValue(0) |
|
36 | 42 | ->min(0) |
|
37 | 42 | ->end() |
|
38 | 42 | ->end() |
|
39 | 42 | ->end() |
|
40 | 42 | ->arrayNode('load_average') |
|
41 | 42 | ->children() |
|
42 | 42 | ->floatNode('max') |
|
43 | 42 | ->defaultValue(100) |
|
44 | 42 | ->min(0) |
|
45 | 42 | ->end() |
|
46 | 42 | ->floatNode('min') |
|
47 | 42 | ->defaultValue(0) |
|
48 | 42 | ->min(0) |
|
49 | 42 | ->end() |
|
50 | 42 | ->end() |
|
51 | 42 | ->end() |
|
52 | 42 | ->end() |
|
53 | 42 | ->end() |
|
54 | 42 | ->arrayNode('triggers') |
|
55 | 42 | ->isRequired() |
|
56 | 42 | ->requiresAtLeastOneElement() |
|
57 | 42 | ->prototype('scalar')->end() |
|
58 | 42 | ->end() |
|
59 | 42 | ->arrayNode('trigger_manager') |
|
60 | 42 | ->addDefaultsIfNotSet() |
|
61 | 42 | ->children() |
|
62 | 42 | ->scalarNode('strategy') |
|
63 | 42 | ->defaultValue(TriggerManager::STRATEGY_AFFIRMATIVE) |
|
64 | 42 | ->end() |
|
65 | 42 | ->booleanNode('allow_if_all_abstain') |
|
66 | 42 | ->defaultFalse() |
|
67 | 42 | ->end() |
|
68 | 42 | ->booleanNode('allow_if_equal_granted_denied') |
|
69 | 42 | ->defaultTrue() |
|
70 | 42 | ->end() |
|
71 | 42 | ->end() |
|
72 | 42 | ->end() |
|
73 | 42 | ->arrayNode('alerting') |
|
74 | 42 | ->children() |
|
75 | 42 | ->scalarNode('email')->end() |
|
76 | 42 | ->arrayNode('webhook') |
|
77 | 42 | ->prototype('scalar')->end() |
|
78 | 42 | ->end() |
|
79 | 42 | ->arrayNode('hipchat') |
|
80 | 42 | ->children() |
|
81 | 42 | ->scalarNode('token')->end() |
|
82 | 42 | ->scalarNode('room')->end() |
|
83 | 42 | ->end() |
|
84 | 42 | ->end() |
|
85 | 42 | ->arrayNode('slack') |
|
86 | 42 | ->children() |
|
87 | 42 | ->scalarNode('token')->end() |
|
88 | 42 | ->scalarNode('channel')->end() |
|
89 | 42 | ->end() |
|
90 | 42 | ->end() |
|
91 | 42 | ->end() |
|
92 | 42 | ->end() |
|
93 | 42 | ->arrayNode('rabbitmq') |
|
94 | 42 | ->children() |
|
95 | 42 | ->arrayNode('queue_depth') |
|
96 | 42 | ->children() |
|
97 | 42 | ->integerNode('history_length') |
|
98 | 42 | ->min(1) |
|
99 | 42 | ->defaultValue(10) |
|
100 | 42 | ->end() |
|
101 | 42 | ->end() |
|
102 | 42 | ->end() |
|
103 | 42 | ->end() |
|
104 | 42 | ->end() |
|
105 | 42 | ->end(); |
|
106 | |||
107 | 42 | return $treeBuilder; |
|
108 | } |
||
109 | } |
||
110 |