Conditions | 1 |
Paths | 1 |
Total Lines | 57 |
Code Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | 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 |
||
35 | public function getConfigTreeBuilder(): TreeBuilder |
||
36 | { |
||
37 | $treeBuilder = new TreeBuilder(); |
||
38 | $rootNode = $treeBuilder->root('teebot'); |
||
39 | $rootNode |
||
40 | ->addDefaultsIfNotSet() |
||
|
|||
41 | ->children() |
||
42 | ->scalarNode('token') |
||
43 | ->isRequired() |
||
44 | ->cannotBeEmpty() |
||
45 | ->end() |
||
46 | ->scalarNode('name') |
||
47 | ->defaultValue(self::DEFAULT_NAME) |
||
48 | ->end() |
||
49 | ->scalarNode('url') |
||
50 | ->defaultValue(self::DEFAULT_URL) |
||
51 | ->end() |
||
52 | ->scalarNode('file_url') |
||
53 | ->defaultValue(self::DEFAULT_FILE_URL) |
||
54 | ->end() |
||
55 | ->scalarNode('method') |
||
56 | ->defaultValue(self::DEFAULT_METHOD) |
||
57 | ->end() |
||
58 | ->scalarNode('bot_prefix') |
||
59 | ->defaultValue(self::BOT_PREFIX) |
||
60 | ->end() |
||
61 | ->scalarNode('timeout') |
||
62 | ->defaultValue(self::DEFAULT_TIMEOUT) |
||
63 | ->end() |
||
64 | ->arrayNode('options') |
||
65 | ->useAttributeAsKey('key') |
||
66 | ->prototype('scalar')->end() |
||
67 | ->end() |
||
68 | ->arrayNode('events') |
||
69 | ->prototype('array') |
||
70 | ->children() |
||
71 | ->scalarNode('command')->end() |
||
72 | ->scalarNode('type')->end() |
||
73 | ->scalarNode('class')->end() |
||
74 | ->arrayNode('params') |
||
75 | ->prototype('array') |
||
76 | ->useAttributeAsKey('key') |
||
77 | ->prototype('scalar')->end() |
||
78 | ->end() |
||
79 | ->end() |
||
80 | ->end() |
||
81 | ->end() |
||
82 | ->end() |
||
83 | ->arrayNode('logger') |
||
84 | ->children() |
||
85 | ->scalarNode('filename') |
||
86 | ->end() |
||
87 | ->end() |
||
88 | ->end() |
||
89 | ->end(); |
||
90 | |||
91 | return $treeBuilder; |
||
92 | } |
||
94 |