| Conditions | 7 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 44 |
| CRAP Score | 7 |
| 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 |
||
| 25 | 4 | public function getConfigTreeBuilder() |
|
| 26 | { |
||
| 27 | 4 | $treeBuilder = new TreeBuilder(); |
|
| 28 | 4 | $rootNode = $treeBuilder->root('runopencode_twig_bufferized_template'); |
|
| 29 | |||
| 30 | $rootNode |
||
| 31 | 4 | ->fixXmlConfig('node') |
|
| 32 | 4 | ->beforeNormalization() |
|
| 33 | 4 | ->always() |
|
| 34 | ->then(function ($value) { |
||
| 35 | |||
| 36 | 4 | if (isset($value['whitelist']) && is_string($value['whitelist'])) { |
|
| 37 | 1 | $value['whitelist'] = [$value['whitelist']]; |
|
| 38 | } |
||
| 39 | |||
| 40 | 4 | if (isset($value['blacklist']) && is_string($value['blacklist'])) { |
|
| 41 | 1 | $value['blacklist'] = [$value['blacklist']]; |
|
| 42 | } |
||
| 43 | |||
| 44 | 4 | if (isset($value['node'])) { |
|
| 45 | |||
| 46 | 1 | $value['node'] = array_map(function($node) { |
|
| 47 | 1 | if (!isset($node['value'])) { |
|
| 48 | 1 | $node['value'] = null; |
|
| 49 | } |
||
| 50 | 1 | return $node; |
|
| 51 | 1 | }, $value['node']); |
|
| 52 | } |
||
| 53 | |||
| 54 | 4 | return $value; |
|
| 55 | 4 | }) |
|
| 56 | 4 | ->end() |
|
| 57 | 4 | ->children() |
|
| 58 | 4 | ->integerNode('node_visitor_priority') |
|
| 59 | 4 | ->info('Twig node visitor priority - it should be highest, bufferization should be executed as latest as possible.') |
|
| 60 | 4 | ->defaultValue(10) |
|
| 61 | 4 | ->end() |
|
| 62 | 4 | ->integerNode('default_execution_priority') |
|
| 63 | 4 | ->info('Default execution priority of bufferized node - if not explicitly provided.') |
|
| 64 | 4 | ->defaultValue(0) |
|
| 65 | 4 | ->end() |
|
| 66 | 4 | ->arrayNode('whitelist') |
|
| 67 | 4 | ->prototype('scalar') |
|
| 68 | 4 | ->end() |
|
| 69 | 4 | ->end() |
|
| 70 | 4 | ->arrayNode('blacklist') |
|
| 71 | 4 | ->prototype('scalar') |
|
| 72 | 4 | ->end() |
|
| 73 | 4 | ->end() |
|
| 74 | 4 | ->arrayNode('nodes') |
|
| 75 | 4 | ->useAttributeAsKey('class') |
|
| 76 | 4 | ->prototype('scalar') |
|
| 77 | 4 | ->end() |
|
| 78 | 4 | ->end() |
|
| 79 | 4 | ->end() |
|
| 80 | 4 | ->end(); |
|
| 81 | |||
| 82 | 4 | return $treeBuilder; |
|
| 83 | } |
||
| 84 | } |
||
| 85 |