Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
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 |
||
22 | public function getConfigTreeBuilder() |
||
23 | { |
||
24 | $treeBuilder = new TreeBuilder(); |
||
25 | |||
26 | $rootNode = $treeBuilder->root('params'); |
||
27 | |||
28 | $rootNode |
||
29 | ->children() |
||
30 | ->scalarNode('user_email') |
||
31 | ->defaultNull() |
||
32 | ->end() |
||
33 | ->scalarNode('user_phone') |
||
34 | ->defaultNull() |
||
35 | ->end() |
||
36 | ->scalarNode('user_full_name') |
||
37 | ->defaultNull() |
||
38 | ->end() |
||
39 | ->scalarNode('subject') |
||
40 | ->isRequired() |
||
41 | ->cannotBeEmpty() |
||
42 | ->end() |
||
43 | ->scalarNode('content') |
||
44 | ->isRequired() |
||
45 | ->cannotBeEmpty() |
||
46 | ->end() |
||
47 | ->scalarNode('content_html') |
||
48 | ->isRequired() |
||
49 | ->cannotBeEmpty() |
||
50 | ->end() |
||
51 | ->scalarNode('group_id') |
||
52 | ->defaultNull() |
||
53 | ->end() |
||
54 | ->scalarNode('language_id') |
||
55 | ->defaultNull() |
||
56 | ->end() |
||
57 | ->arrayNode('custom_fields') |
||
58 | ->prototype('scalar') |
||
59 | ->end() |
||
60 | ->end() |
||
61 | ->arrayNode('labels') |
||
62 | ->end() |
||
63 | ->arrayNode('attachments') |
||
64 | ->prototype('scalar') |
||
65 | ->end() |
||
66 | ->end() |
||
67 | ->scalarNode('priority') |
||
68 | ->defaultNull() |
||
69 | ->validate() |
||
70 | ->ifNotInArray(Cases::PRIORITIES) |
||
71 | ->thenInvalid(sprintf(self::MESSAGE_INVALID_PRIORITY, implode(', ', Cases::PRIORITIES))) |
||
72 | ->end() |
||
73 | ->end() |
||
74 | ->scalarNode('staff_id') |
||
75 | ->defaultNull() |
||
76 | ->end() |
||
77 | ->end(); |
||
78 | |||
79 | return $treeBuilder; |
||
80 | } |
||
81 | } |
||
82 |