Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 50 |
Lines | 0 |
Ratio | 0 % |
Tests | 49 |
CRAP Score | 1 |
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 |
||
18 | 11 | public function getConfigTreeBuilder() |
|
19 | { |
||
20 | 11 | $treeBuilder = new TreeBuilder(); |
|
21 | 11 | $rootNode = $treeBuilder->root('ma27_api_key_authentication'); |
|
22 | |||
23 | $rootNode |
||
24 | 11 | ->children() |
|
25 | 11 | ->arrayNode('user') |
|
26 | 11 | ->children() |
|
27 | 11 | ->integerNode('api_key_length') |
|
28 | 11 | ->min(50) |
|
29 | 11 | ->defaultValue(200) |
|
30 | 11 | ->end() |
|
31 | 11 | ->scalarNode('object_manager')->isRequired()->end() |
|
32 | 11 | ->scalarNode('model_name')->defaultValue('AppBundle\\Entity\\User')->end() |
|
33 | 11 | ->arrayNode('password') |
|
34 | 11 | ->addDefaultsIfNotSet() |
|
35 | 11 | ->children() |
|
36 | 11 | ->scalarNode('strategy') |
|
37 | 11 | ->defaultValue('php55') |
|
38 | 11 | ->end() |
|
39 | 11 | ->end() |
|
40 | 11 | ->end() |
|
41 | 11 | ->scalarNode('metadata_cache')->defaultFalse()->end() |
|
42 | 11 | ->end() |
|
43 | 11 | ->end() |
|
44 | 11 | ->arrayNode('api_key_purge') |
|
45 | 11 | ->canBeEnabled() |
|
46 | 11 | ->children() |
|
47 | 11 | ->arrayNode('last_action_listener') |
|
48 | 11 | ->canBeDisabled() |
|
49 | 11 | ->end() |
|
50 | 11 | ->scalarNode('outdated_rule')->defaultValue('-5 days')->end() |
|
51 | 11 | ->end() |
|
52 | 11 | ->end() |
|
53 | 11 | ->arrayNode('services') |
|
54 | 11 | ->addDefaultsIfNotSet() |
|
55 | 11 | ->children() |
|
56 | 11 | ->scalarNode('auth_handler')->defaultNull()->end() |
|
57 | 11 | ->scalarNode('key_factory')->defaultNull()->end() |
|
58 | 11 | ->end() |
|
59 | 11 | ->end() |
|
60 | 11 | ->scalarNode('key_header')->defaultValue('X-API-KEY')->end() |
|
61 | 11 | ->arrayNode('response') |
|
62 | 11 | ->addDefaultsIfNotSet() |
|
63 | 11 | ->children() |
|
64 | 11 | ->scalarNode('api_key_property')->defaultValue('apiKey')->end() |
|
65 | 11 | ->scalarNode('error_property')->defaultValue('message')->end() |
|
66 | 11 | ->end() |
|
67 | 11 | ->end() |
|
68 | 11 | ->end(); |
|
69 | |||
70 | 11 | return $treeBuilder; |
|
71 | } |
||
72 | } |
||
73 |