Conditions | 4 |
Paths | 2 |
Total Lines | 58 |
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(): TreeBuilder |
||
20 | { |
||
21 | if (true === method_exists(TreeBuilder::class, 'getRootNode')) { |
||
22 | $treeBuilder = new TreeBuilder('fsi_admin'); |
||
23 | $rootNode = $treeBuilder->getRootNode(); |
||
24 | } else { |
||
25 | $treeBuilder = new TreeBuilder(); |
||
26 | $rootNode = $treeBuilder->root('fsi_admin'); |
||
27 | } |
||
28 | |||
29 | $rootNode |
||
30 | ->validate() |
||
31 | ->always(function($v) { |
||
32 | if (!isset($v['templates']['crud_list'])) { |
||
33 | $v['templates']['crud_list'] = $v['templates']['list']; |
||
34 | } |
||
35 | if (!isset($v['templates']['crud_form'])) { |
||
36 | $v['templates']['crud_form'] = $v['templates']['form']; |
||
37 | } |
||
38 | return $v; |
||
39 | }) |
||
40 | ->end() |
||
41 | ->children() |
||
42 | ->scalarNode('default_locale')->defaultValue('%locale%')->end() |
||
43 | ->arrayNode('locales') |
||
44 | ->prototype('scalar')->end() |
||
45 | ->defaultValue(['%locale%']) |
||
46 | ->end() |
||
47 | ->scalarNode('menu_config_path')->defaultValue("%kernel.root_dir%/config/admin_menu.yml")->end() |
||
48 | ->arrayNode('templates') |
||
49 | ->addDefaultsIfNotSet() |
||
50 | ->children() |
||
51 | ->scalarNode('base')->defaultValue('@FSiAdmin/base.html.twig')->end() |
||
52 | ->scalarNode('index_page')->defaultValue('@FSiAdmin/Admin/index.html.twig')->end() |
||
53 | ->scalarNode('list')->defaultValue('@FSiAdmin/List/list.html.twig')->end() |
||
54 | ->scalarNode('form')->defaultValue('@FSiAdmin/Form/form.html.twig')->end() |
||
55 | ->scalarNode('crud_list')->defaultValue('@FSiAdmin/CRUD/list.html.twig')->end() |
||
56 | ->scalarNode('crud_form')->defaultNull()->end() |
||
57 | ->scalarNode('resource')->defaultValue('@FSiAdmin/Resource/resource.html.twig')->end() |
||
58 | ->scalarNode('display')->defaultValue('@FSiAdmin/Display/display.html.twig')->end() |
||
59 | ->scalarNode('datagrid_theme')->defaultValue('@FSiAdmin/CRUD/datagrid.html.twig')->end() |
||
60 | ->scalarNode('datasource_theme')->defaultValue('@FSiAdmin/CRUD/datasource.html.twig')->end() |
||
61 | ->scalarNode('form_theme')->defaultValue('@FSiAdmin/Form/form_theme.html.twig')->end() |
||
62 | ->end() |
||
63 | ->end() |
||
64 | ->arrayNode('annotations') |
||
65 | ->addDefaultsIfNotSet() |
||
66 | ->children() |
||
67 | ->arrayNode('dirs') |
||
68 | ->prototype('scalar')->defaultValue([])->end() |
||
69 | ->end() |
||
70 | ->end() |
||
71 | ->end() |
||
72 | ->end() |
||
73 | ; |
||
74 | |||
75 | return $treeBuilder; |
||
76 | } |
||
77 | } |
||
78 |