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