Conditions | 1 |
Paths | 1 |
Total Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
17 | public function getConfigTreeBuilder() |
||
18 | { |
||
19 | $treeBuilder = new TreeBuilder(); |
||
20 | |||
21 | $rootNode = $treeBuilder->root('params'); |
||
22 | |||
23 | $rootNode |
||
24 | ->children() |
||
25 | ->scalarNode('user_email') |
||
26 | ->defaultNull() |
||
27 | ->end() |
||
28 | ->scalarNode('user_phone') |
||
29 | ->defaultNull() |
||
30 | ->end() |
||
31 | ->scalarNode('user_full_name') |
||
32 | ->defaultNull() |
||
33 | ->end() |
||
34 | ->scalarNode('subject') |
||
35 | ->isRequired() |
||
36 | ->cannotBeEmpty() |
||
37 | ->end() |
||
38 | ->scalarNode('content') |
||
39 | ->isRequired() |
||
40 | ->cannotBeEmpty() |
||
41 | ->end() |
||
42 | ->scalarNode('content_html') |
||
43 | ->isRequired() |
||
44 | ->cannotBeEmpty() |
||
45 | ->end() |
||
46 | ->scalarNode('group_id') |
||
47 | ->defaultNull() |
||
48 | ->end() |
||
49 | ->scalarNode('language_id') |
||
50 | ->defaultNull() |
||
51 | ->end() |
||
52 | ->arrayNode('custom_fields') |
||
53 | ->prototype('scalar') |
||
54 | ->end() |
||
55 | ->end() |
||
56 | ->arrayNode('labels') |
||
57 | ->end() |
||
58 | ->arrayNode('attachments') |
||
59 | ->prototype('scalar') |
||
60 | ->end() |
||
61 | ->end() |
||
62 | ->scalarNode('priority') |
||
63 | ->defaultNull(Cases::PRIORITY_LOW) |
||
64 | ->end() |
||
65 | ->scalarNode('staff_id') |
||
66 | ->defaultNull() |
||
67 | ->end() |
||
68 | ->end(); |
||
69 | |||
70 | return $treeBuilder; |
||
71 | } |
||
72 | } |
||
73 |