| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 39 |
| CRAP Score | 1 |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 25 | 1 | public function getConfigTreeBuilder() |
|
| 26 | { |
||
| 27 | 1 | $treeBuilder = new TreeBuilder(); |
|
| 28 | 1 | $rootNode = $treeBuilder->root('meup_tagcommander'); |
|
| 29 | |||
| 30 | $rootNode |
||
| 31 | 1 | ->children() |
|
| 32 | |||
| 33 | 1 | ->scalarNode('default_event') |
|
| 34 | 1 | ->defaultValue('default') |
|
| 35 | 1 | ->end() |
|
| 36 | |||
| 37 | 1 | ->arrayNode('datalayer') |
|
| 38 | 1 | ->children() |
|
| 39 | 1 | ->scalarNode('name') |
|
| 40 | 1 | ->defaultValue('tc_vars') |
|
| 41 | 1 | ->end() |
|
| 42 | 1 | ->variableNode('default')->end() |
|
| 43 | 1 | ->end() |
|
| 44 | 1 | ->end() |
|
| 45 | |||
| 46 | 1 | ->arrayNode('containers') |
|
| 47 | 1 | ->isRequired() |
|
| 48 | 1 | ->requiresAtLeastOneElement() |
|
| 49 | 1 | ->prototype('array') |
|
| 50 | 1 | ->children() |
|
| 51 | 1 | ->scalarNode('name') |
|
| 52 | 1 | ->isRequired() |
|
| 53 | 1 | ->end() |
|
| 54 | 1 | ->scalarNode('script') |
|
| 55 | 1 | ->isRequired() |
|
| 56 | 1 | ->end() |
|
| 57 | 1 | ->scalarNode('version') |
|
| 58 | ->defaultValue('') |
||
| 59 | 1 | ->end() |
|
| 60 | 1 | ->scalarNode('alternative') |
|
| 61 | 1 | ->defaultValue('') |
|
| 62 | 1 | ->end() |
|
| 63 | 1 | ->end() |
|
| 64 | 1 | ->end() |
|
| 65 | 1 | ->end() |
|
| 66 | 1 | ||
| 67 | 1 | ->arrayNode('events') |
|
| 68 | 1 | ->isRequired() |
|
| 69 | ->requiresAtLeastOneElement() |
||
| 70 | 1 | ->prototype('array') |
|
| 71 | ->children() |
||
| 72 | ->scalarNode('name')->end() |
||
| 73 | 1 | ->scalarNode('function')->end() |
|
| 74 | ->end() |
||
| 75 | ->end() |
||
| 76 | ->end() |
||
| 77 | |||
| 78 | ->end() |
||
| 79 | ; |
||
| 80 | |||
| 81 | return $treeBuilder; |
||
| 82 | } |
||
| 83 | } |
||
| 84 |