Conditions | 2 |
Paths | 2 |
Total Lines | 56 |
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 |
||
19 | public function getConfigTreeBuilder() |
||
20 | { |
||
21 | $treeBuilder = new TreeBuilder('kunstmaan_node'); |
||
22 | if (method_exists($treeBuilder, 'getRootNode')) { |
||
23 | $rootNode = $treeBuilder->getRootNode(); |
||
24 | } else { |
||
25 | // BC layer for symfony/config 4.1 and older |
||
26 | $rootNode = $treeBuilder->root('kunstmaan_node'); |
||
27 | } |
||
28 | |||
29 | /* @var ArrayNodeDefinition $pages */ |
||
30 | $rootNode |
||
31 | ->children() |
||
32 | ->arrayNode('pages') |
||
33 | ->prototype('array') |
||
34 | ->children() |
||
35 | ->scalarNode('name')->isRequired()->end() |
||
36 | ->scalarNode('search_type')->end() |
||
37 | ->booleanNode('structure_node')->end() |
||
38 | ->booleanNode('indexable')->end() |
||
39 | ->scalarNode('icon')->defaultNull()->end() |
||
40 | ->scalarNode('hidden_from_tree')->end() |
||
41 | ->booleanNode('is_homepage')->end() |
||
42 | ->arrayNode('allowed_children') |
||
43 | ->prototype('array') |
||
44 | ->beforeNormalization() |
||
45 | ->ifString()->then(function ($v) { |
||
46 | return ['class' => $v]; |
||
47 | }) |
||
48 | ->end() |
||
49 | ->children() |
||
50 | ->scalarNode('class')->isRequired()->end() |
||
51 | ->scalarNode('name')->end() |
||
52 | ->end() |
||
53 | ->end() |
||
54 | ->end() |
||
55 | ->end() |
||
56 | ->end() |
||
57 | ->end() |
||
58 | ->scalarNode('publish_later_stepping')->defaultValue('15')->end() |
||
59 | ->scalarNode('unpublish_later_stepping')->defaultValue('15')->end() |
||
60 | ->booleanNode('show_add_homepage')->defaultTrue()->end() |
||
61 | ->booleanNode('enable_export_page_template')->defaultFalse()->end() |
||
62 | ->arrayNode('lock') |
||
63 | ->addDefaultsIfNotSet() |
||
64 | ->canBeEnabled() |
||
65 | ->children() |
||
66 | ->scalarNode('check_interval')->defaultValue(15)->end() |
||
67 | ->scalarNode('threshold')->defaultValue(35)->end() |
||
68 | ->booleanNode('enabled')->defaultFalse()->end() |
||
69 | ->end() |
||
70 | ->end() |
||
71 | ->end(); |
||
72 | |||
73 | return $treeBuilder; |
||
74 | } |
||
75 | } |
||
76 |