| Conditions | 2 |
| Paths | 1 |
| Total Lines | 61 |
| Code Lines | 56 |
| 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 declare(strict_types=1); |
||
| 14 | public function getConfigTreeBuilder(): TreeBuilder |
||
| 15 | { |
||
| 16 | $treeBuilder = new TreeBuilder('elasticsearch'); |
||
| 17 | |||
| 18 | $debug = EnvironmentHelper::getVariable('APP_ENV', 'prod') !== 'prod'; |
||
| 19 | |||
| 20 | $rootNode = $treeBuilder->getRootNode(); |
||
| 21 | $rootNode |
||
| 22 | ->children() |
||
| 23 | ->booleanNode('enabled')->end() |
||
| 24 | ->booleanNode('indexing_enabled')->end() |
||
| 25 | ->integerNode('indexing_batch_size')->defaultValue(100)->end() |
||
| 26 | ->scalarNode('hosts')->end() |
||
| 27 | ->scalarNode('index_prefix')->end() |
||
| 28 | ->scalarNode('throw_exception')->end() |
||
| 29 | ->scalarNode('logger_level')->defaultValue($debug ? Level::Debug : Level::Error)->end() |
||
| 30 | ->arrayNode('ssl') |
||
| 31 | ->children() |
||
| 32 | ->scalarNode('cert_path')->end() |
||
| 33 | ->scalarNode('cert_password')->end() |
||
| 34 | ->scalarNode('cert_key_path')->end() |
||
| 35 | ->scalarNode('cert_key_password')->end() |
||
| 36 | ->booleanNode('verify_server_cert')->defaultValue(true)->end() |
||
| 37 | ->end() |
||
| 38 | ->end() |
||
| 39 | ->arrayNode('index_settings')->variablePrototype()->end()->end() |
||
| 40 | ->arrayNode('analysis')->performNoDeepMerging()->variablePrototype()->end()->end() |
||
| 41 | ->arrayNode('dynamic_templates')->performNoDeepMerging()->variablePrototype()->end()->end() |
||
| 42 | ->arrayNode('product') |
||
| 43 | ->children() |
||
| 44 | ->arrayNode('custom_fields_mapping') |
||
| 45 | ->variablePrototype()->end() |
||
| 46 | ->end() |
||
| 47 | ->end() |
||
| 48 | ->end() |
||
| 49 | ->arrayNode('search') |
||
| 50 | ->children() |
||
| 51 | ->scalarNode('timeout')->end() |
||
| 52 | ->integerNode('term_max_length')->end() |
||
| 53 | ->end() |
||
| 54 | ->end() |
||
| 55 | ->arrayNode('administration') |
||
| 56 | ->children() |
||
| 57 | ->scalarNode('hosts')->end() |
||
| 58 | ->booleanNode('enabled')->end() |
||
| 59 | ->booleanNode('refresh_indices')->end() |
||
| 60 | ->scalarNode('index_prefix')->end() |
||
| 61 | ->arrayNode('index_settings')->variablePrototype()->end()->end() |
||
| 62 | ->arrayNode('analysis')->performNoDeepMerging()->variablePrototype()->end()->end() |
||
| 63 | ->arrayNode('dynamic_templates')->performNoDeepMerging()->variablePrototype()->end()->end() |
||
| 64 | ->arrayNode('search') |
||
| 65 | ->children() |
||
| 66 | ->scalarNode('timeout')->end() |
||
| 67 | ->integerNode('term_max_length')->end() |
||
| 68 | ->end() |
||
| 69 | ->end() |
||
| 70 | ->end() |
||
| 71 | ->end() |
||
| 72 | ->end(); |
||
| 73 | |||
| 74 | return $treeBuilder; |
||
| 75 | } |
||
| 77 |