Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Tests | 39 |
CRAP Score | 1 |
Changes | 6 | ||
Bugs | 1 | Features | 1 |
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 | public function getConfigTreeBuilder() |
||
19 | 10 | { |
|
20 | $treeBuilder = new TreeBuilder(); |
||
21 | 10 | $rootNode = $treeBuilder->root('ma27_api_key_authentication'); |
|
22 | 10 | ||
23 | $rootNode |
||
24 | ->children() |
||
25 | 10 | ->arrayNode('user') |
|
26 | 10 | ->children() |
|
27 | 10 | ->integerNode('api_key_length') |
|
28 | 10 | ->min(50) |
|
29 | 10 | ->defaultValue(200) |
|
30 | 10 | ->end() |
|
31 | 10 | ->scalarNode('object_manager')->isRequired()->end() |
|
32 | 10 | ->scalarNode('model_name')->defaultValue('AppBundle\\Entity\\User')->end() |
|
33 | 10 | ->arrayNode('password') |
|
34 | 10 | ->children() |
|
35 | 10 | ->scalarNode('strategy') |
|
36 | ->validate() |
||
37 | ->ifNotInArray(array('php55', 'crypt', 'sha512', 'phpass')) |
||
38 | 9 | ->thenInvalid( |
|
39 | 9 | 'Invalid password strategy "%s"! ' |
|
40 | 9 | .'Allowed strategies are "password", "crypt", "sha512", "phpass"!' |
|
41 | ) |
||
42 | 9 | ->end() |
|
43 | 1 | ->end() |
|
44 | ->integerNode('phpass_iteration_length') |
||
45 | ->defaultValue(8) |
||
46 | 8 | ->end() |
|
47 | 1 | ->end() |
|
48 | 1 | ->end() |
|
49 | 1 | ->end() |
|
50 | 1 | ->end() |
|
51 | ->arrayNode('api_key_purge') |
||
52 | 1 | ->canBeEnabled() |
|
53 | ->children() |
||
54 | 1 | ->booleanNode('log_state')->defaultFalse()->end() |
|
55 | 1 | ->scalarNode('logger_service')->defaultValue('logger')->end() |
|
56 | 1 | ->end() |
|
57 | 1 | ->end() |
|
58 | 1 | ->arrayNode('services') |
|
59 | 1 | ->addDefaultsIfNotSet() |
|
60 | ->children() |
||
61 | ->scalarNode('auth_handler')->defaultNull()->end() |
||
62 | 7 | ->scalarNode('key_factory')->defaultNull()->end() |
|
63 | 10 | ->scalarNode('password_hasher')->defaultNull()->end() |
|
64 | 10 | ->end() |
|
65 | 10 | ->end() |
|
66 | 10 | ->end(); |
|
67 | 10 | ||
68 | 10 | return $treeBuilder; |
|
69 | 10 | } |
|
70 | } |
||
71 |