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