| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 2 |
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 |
||
| 16 | public function getConfigTreeBuilder() |
||
| 17 | { |
||
| 18 | $treeBuilder = new TreeBuilder(); |
||
| 19 | |||
| 20 | $treeBuilder->root('sonata_seo') |
||
| 21 | ->children() |
||
| 22 | ->scalarNode('encoding')->defaultValue('UTF-8')->end() |
||
| 23 | ->arrayNode('page') |
||
| 24 | ->addDefaultsIfNotSet() |
||
| 25 | ->children() |
||
| 26 | ->scalarNode('default')->defaultValue('sonata.seo.page.default')->end() |
||
| 27 | ->arrayNode('head') |
||
| 28 | ->normalizeKeys(false) |
||
| 29 | ->useAttributeAsKey('attribute') |
||
| 30 | ->prototype('scalar')->end() |
||
| 31 | ->end() |
||
| 32 | ->arrayNode('html_tag') |
||
| 33 | ->normalizeKeys(false) |
||
| 34 | ->useAttributeAsKey('attribute') |
||
| 35 | ->prototype('scalar')->end() |
||
| 36 | ->end() |
||
| 37 | ->arrayNode('head_tag') |
||
| 38 | ->normalizeKeys(false) |
||
| 39 | ->useAttributeAsKey('attribute') |
||
| 40 | ->prototype('scalar')->end() |
||
| 41 | ->end() |
||
| 42 | ->arrayNode('metas') |
||
| 43 | ->normalizeKeys(false) |
||
| 44 | ->useAttributeAsKey('element') |
||
| 45 | ->prototype('array') |
||
| 46 | ->normalizeKeys(false) |
||
| 47 | ->useAttributeAsKey('name') |
||
| 48 | ->prototype('scalar')->end() |
||
| 49 | ->end() |
||
| 50 | ->end() |
||
| 51 | ->scalarNode('separator')->defaultValue(' - ')->end() |
||
| 52 | ->scalarNode('title')->defaultValue('Sonata Project')->end() |
||
| 53 | ->end() |
||
| 54 | ->end() |
||
| 55 | ->arrayNode('sitemap') |
||
| 56 | ->addDefaultsIfNotSet() |
||
| 57 | ->children() |
||
| 58 | ->arrayNode('doctrine_orm') |
||
| 59 | ->prototype('variable')->end() |
||
| 60 | ->end() |
||
| 61 | ->arrayNode('services') |
||
| 62 | ->prototype('variable')->end() |
||
| 63 | ->end() |
||
| 64 | ->end() |
||
| 65 | ->end() |
||
| 66 | ->end() |
||
| 67 | ; |
||
| 68 | |||
| 69 | return $treeBuilder; |
||
| 70 | } |
||
| 71 | } |
||
| 72 |