| Conditions | 3 |
| Paths | 1 |
| Total Lines | 90 |
| Code Lines | 80 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 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 |
||
| 10 | public function getConfigTreeBuilder(): TreeBuilder |
||
| 11 | { |
||
| 12 | $treeBuilder = new TreeBuilder('locastic_activity_log'); |
||
| 13 | |||
| 14 | $rootNode = $treeBuilder->getRootNode(); |
||
| 15 | |||
| 16 | $rootNode |
||
| 17 | ->children() |
||
| 18 | ->booleanNode('default_doctrine_subscriber') |
||
| 19 | ->defaultTrue() |
||
| 20 | ->end() |
||
| 21 | ->booleanNode('identifier_extractor') |
||
|
|
|||
| 22 | ->defaultTrue() |
||
| 23 | ->end() |
||
| 24 | ->arrayNode('loggable_classes') |
||
| 25 | ->arrayPrototype() |
||
| 26 | ->children() |
||
| 27 | ->scalarNode('class')->end() |
||
| 28 | ->arrayNode('groups') |
||
| 29 | ->prototype('scalar')->end() |
||
| 30 | ->end() |
||
| 31 | ->end() |
||
| 32 | ->end() |
||
| 33 | ->end() |
||
| 34 | ->scalarNode('elastic_host') |
||
| 35 | ->cannotBeEmpty() |
||
| 36 | ->defaultValue('http://localhost:9200') |
||
| 37 | ->end() |
||
| 38 | ->arrayNode('loggable_paths') |
||
| 39 | ->prototype('scalar')->end() |
||
| 40 | ->end() |
||
| 41 | ->booleanNode('elastic_date_detection') |
||
| 42 | ->defaultValue(true) |
||
| 43 | ->end() |
||
| 44 | ->scalarNode('elastic_dynamic_date_formats') |
||
| 45 | ->cannotBeEmpty() |
||
| 46 | ->defaultValue('strict_date_optional_time||epoch_millis||strict_time') |
||
| 47 | ->end() |
||
| 48 | ->arrayNode('activity_log') |
||
| 49 | ->addDefaultsIfNotSet() |
||
| 50 | ->children() |
||
| 51 | ->arrayNode('elastic_properties') |
||
| 52 | ->arrayPrototype() |
||
| 53 | ->validate() |
||
| 54 | ->always(function($v){ |
||
| 55 | if (empty($v['properties'])) { |
||
| 56 | unset($v['properties']); |
||
| 57 | } |
||
| 58 | return $v; |
||
| 59 | }) |
||
| 60 | ->end() |
||
| 61 | ->children() |
||
| 62 | ->scalarNode('type')->end() |
||
| 63 | ->arrayNode('properties') |
||
| 64 | ->arrayPrototype()->scalarPrototype()->end()->end() |
||
| 65 | ->end() |
||
| 66 | ->end() |
||
| 67 | ->end() |
||
| 68 | ->defaultValue($this->getActivityLogProperties()) |
||
| 69 | ->end() |
||
| 70 | ->end() |
||
| 71 | ->end() |
||
| 72 | ->arrayNode('current_data_tracker') |
||
| 73 | ->addDefaultsIfNotSet() |
||
| 74 | ->children() |
||
| 75 | ->arrayNode('elastic_properties') |
||
| 76 | ->arrayPrototype() |
||
| 77 | ->validate() |
||
| 78 | ->always(function($v){ |
||
| 79 | if (empty($v['properties'])) { |
||
| 80 | unset($v['properties']); |
||
| 81 | } |
||
| 82 | return $v; |
||
| 83 | }) |
||
| 84 | ->end() |
||
| 85 | ->children() |
||
| 86 | ->scalarNode('type')->end() |
||
| 87 | ->arrayNode('properties') |
||
| 88 | ->arrayPrototype()->scalarPrototype()->end()->end() |
||
| 89 | ->end() |
||
| 90 | ->end() |
||
| 91 | ->end() |
||
| 92 | ->defaultValue($this->getCurrentDataTrackerProperties()) |
||
| 93 | ->end() |
||
| 94 | ->end() |
||
| 95 | ->end() |
||
| 96 | ->end() |
||
| 97 | ; |
||
| 98 | |||
| 99 | return $treeBuilder; |
||
| 100 | } |
||
| 131 |