Conditions | 1 |
Paths | 1 |
Total Lines | 76 |
Code Lines | 69 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
27 | public function getConfigTreeBuilder() |
||
28 | { |
||
29 | $treeBuilder = new TreeBuilder(); |
||
30 | $rootNode = $treeBuilder->root('sonata_news'); |
||
31 | |||
32 | $rootNode |
||
33 | ->children() |
||
34 | ->scalarNode('title')->isRequired()->end() |
||
35 | ->scalarNode('link')->isRequired()->end() |
||
36 | ->scalarNode('description')->isRequired()->end() |
||
37 | ->scalarNode('permalink_generator')->defaultValue('sonata.news.permalink.date')->end() |
||
38 | ->scalarNode('salt')->isRequired()->end() |
||
39 | ->arrayNode('permalink') |
||
40 | ->addDefaultsIfNotSet() |
||
41 | ->children() |
||
42 | ->scalarNode('date')->defaultValue('%%1$04d/%%2$d/%%3$d/%%4$s')->end() // year/month/day/slug |
||
43 | ->end() |
||
44 | ->end() |
||
45 | ->arrayNode('table') |
||
46 | ->addDefaultsIfNotSet() |
||
47 | ->children() |
||
48 | ->scalarNode('post_tag')->defaultValue('news__post_tag')->end() |
||
49 | ->end() |
||
50 | ->end() |
||
51 | ->arrayNode('class') |
||
52 | ->addDefaultsIfNotSet() |
||
53 | ->children() |
||
54 | ->scalarNode('tag')->defaultValue('Application\\Sonata\\ClassificationBundle\\Entity\\Tag')->end() |
||
55 | ->scalarNode('collection')->defaultValue('Application\\Sonata\\ClassificationBundle\\Entity\\Collection')->end() |
||
56 | ->scalarNode('post')->defaultValue('Application\\Sonata\\NewsBundle\\Entity\\Post')->end() |
||
57 | ->scalarNode('comment')->defaultValue('Application\\Sonata\\NewsBundle\\Entity\\Comment')->end() |
||
58 | ->scalarNode('media')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\Media')->end() |
||
59 | ->scalarNode('user')->defaultValue('Application\\Sonata\\UserBundle\\Entity\\User')->end() |
||
60 | ->end() |
||
61 | ->end() |
||
62 | |||
63 | ->arrayNode('admin') |
||
64 | ->addDefaultsIfNotSet() |
||
65 | ->children() |
||
66 | ->arrayNode('post') |
||
67 | ->addDefaultsIfNotSet() |
||
68 | ->children() |
||
69 | ->scalarNode('class')->cannotBeEmpty()->defaultValue('Sonata\\NewsBundle\\Admin\\PostAdmin')->end() |
||
70 | ->scalarNode('controller')->cannotBeEmpty()->defaultValue('SonataAdminBundle:CRUD')->end() |
||
71 | ->scalarNode('translation')->cannotBeEmpty()->defaultValue('SonataNewsBundle')->end() |
||
72 | ->end() |
||
73 | ->end() |
||
74 | ->arrayNode('comment') |
||
75 | ->addDefaultsIfNotSet() |
||
76 | ->children() |
||
77 | ->scalarNode('class')->cannotBeEmpty()->defaultValue('Sonata\\NewsBundle\\Admin\\CommentAdmin')->end() |
||
78 | ->scalarNode('controller')->cannotBeEmpty()->defaultValue('SonataNewsBundle:CommentAdmin')->end() |
||
79 | ->scalarNode('translation')->cannotBeEmpty()->defaultValue('SonataNewsBundle')->end() |
||
80 | ->end() |
||
81 | ->end() |
||
82 | ->end() |
||
83 | ->end() |
||
84 | |||
85 | ->arrayNode('comment') |
||
86 | ->children() |
||
87 | ->arrayNode('notification') |
||
88 | ->children() |
||
89 | ->arrayNode('emails') |
||
90 | ->prototype('scalar')->cannotBeEmpty()->end() |
||
91 | ->end() |
||
92 | ->scalarNode('from')->cannotBeEmpty()->end() |
||
93 | ->scalarNode('template')->cannotBeEmpty()->end() |
||
94 | ->end() |
||
95 | ->end() |
||
96 | ->end() |
||
97 | ->end() |
||
98 | ->end() |
||
99 | ; |
||
100 | |||
101 | return $treeBuilder; |
||
102 | } |
||
103 | } |
||
104 |