Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
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 |
||
19 | public function getConfigTreeBuilder() |
||
20 | { |
||
21 | $builder = new TreeBuilder(); |
||
22 | |||
23 | $builder->root('webuni_commonmark', 'array') |
||
24 | ->addDefaultsIfNotSet() |
||
25 | ->children() |
||
26 | ->scalarNode('default_converter')->defaultValue('default')->end() |
||
27 | ->arrayNode('extensions') |
||
28 | ->addDefaultsIfNotSet() |
||
29 | ->children() |
||
30 | ->booleanNode('attributes')->defaultTrue()->end() |
||
31 | ->booleanNode('table')->defaultTrue()->end() |
||
32 | ->end() |
||
33 | ->end() |
||
34 | ->arrayNode('converters') |
||
35 | ->defaultValue(['default' => [ |
||
36 | 'converter' => 'webuni_commonmark.converter', |
||
37 | 'environment' => 'webuni_commonmark.default_environment', |
||
38 | 'parser' => 'webuni_commonmark.docparser', |
||
39 | 'renderer' => 'webuni_commonmark.htmlrenderer', |
||
40 | 'config' => [], |
||
41 | 'extensions' => [], |
||
42 | ]]) |
||
43 | ->beforeNormalization() |
||
44 | ->always() |
||
45 | ->then(function ($v) { |
||
46 | return array_merge(['default' => null], $v); |
||
47 | }) |
||
48 | ->end() |
||
49 | ->prototype('array') |
||
50 | ->addDefaultsIfNotSet() |
||
51 | ->children() |
||
52 | ->scalarNode('converter')->defaultValue('webuni_commonmark.converter')->end() |
||
53 | ->scalarNode('environment')->defaultValue('webuni_commonmark.default_environment')->end() |
||
54 | ->scalarNode('parser')->defaultValue('webuni_commonmark.docparser')->end() |
||
55 | ->scalarNode('renderer')->defaultValue('webuni_commonmark.htmlrenderer')->end() |
||
56 | ->arrayNode('config') |
||
57 | ->prototype('variable') |
||
58 | ->defaultValue([]) |
||
59 | ->end() |
||
60 | ->end() |
||
61 | ->arrayNode('extensions') |
||
62 | ->defaultValue([]) |
||
63 | ->prototype('scalar')->end() |
||
64 | ->end() |
||
65 | ->end() |
||
66 | ->end() |
||
67 | ->end() |
||
68 | ->end() |
||
69 | ; |
||
70 | |||
71 | return $builder; |
||
72 | } |
||
73 | } |
||
74 |