Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
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 |
||
36 | public function configure(ArrayNodeDefinition $builder) |
||
37 | { |
||
38 | $builder |
||
39 | ->children() |
||
40 | ->scalarNode('base_url') |
||
41 | ->isRequired() |
||
42 | ->cannotBeEmpty() |
||
43 | ->end() |
||
44 | |||
45 | ->arrayNode('debug') |
||
46 | ->addDefaultsIfNotSet() |
||
47 | ->children() |
||
48 | ->scalarNode('formatter') |
||
49 | ->defaultValue('pretty') |
||
50 | ->end() |
||
51 | |||
52 | ->arrayNode('headers') |
||
53 | ->info('Headers to print in DebugHttp listener') |
||
54 | ->addDefaultsIfNotSet() |
||
55 | ->children() |
||
56 | ->arrayNode('request') |
||
57 | ->info('Request headers to print in DebugHttp listener') |
||
58 | ->defaultValue(['Content-Type']) |
||
59 | ->prototype('scalar')->end() |
||
60 | ->end() |
||
61 | |||
62 | ->arrayNode('response') |
||
63 | ->info('Response headers to print in DebugHttp listener') |
||
64 | ->defaultValue(['Content-Type']) |
||
65 | ->prototype('scalar')->end() |
||
66 | ->end() |
||
67 | ->end() |
||
68 | ->end() |
||
69 | ->end() |
||
70 | ->end() |
||
71 | |||
72 | ->arrayNode('twig') |
||
73 | ->addDefaultsIfNotSet() |
||
74 | ->children() |
||
75 | ->scalarNode('cache') |
||
76 | ->defaultNull() |
||
77 | ->beforeNormalization() |
||
78 | ->ifEmpty() |
||
79 | ->thenUnset() |
||
80 | ->end() |
||
81 | ->validate() |
||
82 | ->ifTrue(function ($v) { return !is_dir($v); }) |
||
83 | ->thenInvalid('Directory does not exist') |
||
84 | ->end() |
||
85 | ->end() |
||
86 | ->enumNode('autoescape') |
||
87 | ->values([false, 'html', 'js', 'name']) |
||
88 | ->defaultFalse() |
||
89 | ->end() |
||
90 | ->end() |
||
91 | ->end() |
||
92 | ->end() |
||
93 | ->end(); |
||
94 | |||
95 | } |
||
96 | |||
158 |