| Conditions | 1 |
| Paths | 1 |
| Total Lines | 76 |
| Code Lines | 70 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 2 |
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 |
||
| 11 | public function getConfigTreeBuilder() |
||
| 12 | { |
||
| 13 | $tree = new TreeBuilder(); |
||
| 14 | $rootNode = $tree->root('cmobi_rabbitmq'); |
||
| 15 | $rootNode |
||
| 16 | ->children() |
||
| 17 | ->scalarNode('basic_qos')->defaultValue(1)->end() |
||
| 18 | ->end(); |
||
| 19 | $rootNode->fixXmlConfig('connection') |
||
| 20 | ->children() |
||
| 21 | ->arrayNode('connections') |
||
| 22 | ->useAttributeAsKey('key') |
||
| 23 | ->prototype('array') |
||
| 24 | ->children() |
||
| 25 | ->scalarNode('host')->defaultValue('localhost')->end() |
||
| 26 | ->scalarNode('port')->defaultValue(5672)->end() |
||
| 27 | ->scalarNode('user')->defaultValue('guest')->end() |
||
| 28 | ->scalarNode('password')->defaultValue('guest')->end() |
||
| 29 | ->scalarNode('vhost')->defaultValue('/')->end() |
||
| 30 | ->booleanNode('lazy')->defaultFalse()->end() |
||
| 31 | ->scalarNode('connection_timeout')->defaultValue(3)->end() |
||
| 32 | ->scalarNode('read_write_timeout')->defaultValue(3)->end() |
||
| 33 | ->arrayNode('ssl_context') |
||
| 34 | ->useAttributeAsKey('key') |
||
| 35 | ->canBeUnset() |
||
| 36 | ->prototype('variable')->end() |
||
| 37 | ->end() |
||
| 38 | ->booleanNode('keepalive')->defaultFalse()->info('requires php-amqplib v2.4.1+ and PHP5.4+')->end() |
||
| 39 | ->scalarNode('heartbeat')->defaultValue(0)->info('requires php-amqplib v2.4.1+')->end() |
||
| 40 | ->end() |
||
| 41 | ->end() |
||
| 42 | ->end() |
||
| 43 | ->end() |
||
| 44 | ; |
||
| 45 | $rootNode |
||
| 46 | ->children() |
||
| 47 | ->arrayNode('router') |
||
| 48 | ->info('router configuration') |
||
| 49 | ->canBeUnset() |
||
| 50 | ->children() |
||
| 51 | ->scalarNode('resource')->isRequired()->end() |
||
| 52 | ->end() |
||
| 53 | ->end() |
||
| 54 | ->end() |
||
| 55 | ; |
||
| 56 | $rootNode->fixXmlConfig('rpc_server') |
||
| 57 | ->children() |
||
| 58 | ->arrayNode('rpc_servers') |
||
| 59 | ->useAttributeAsKey('key') |
||
| 60 | ->prototype('array') |
||
| 61 | ->children() |
||
| 62 | ->arrayNode('queue') |
||
| 63 | ->children() |
||
| 64 | ->scalarNode('name')->end() |
||
| 65 | ->booleanNode('passive')->defaultFalse()->end() |
||
| 66 | ->booleanNode('durable')->defaultTrue()->end() |
||
| 67 | ->booleanNode('exclusive')->defaultFalse()->end() |
||
| 68 | ->booleanNode('auto_delete')->defaultFalse()->end() |
||
| 69 | ->booleanNode('nowait')->defaultFalse()->end() |
||
| 70 | ->variableNode('arguments')->defaultNull()->end() |
||
| 71 | ->scalarNode('ticket')->defaultNull()->end() |
||
| 72 | ->arrayNode('routing_keys') |
||
| 73 | ->prototype('scalar')->end() |
||
| 74 | ->end() |
||
| 75 | ->end() |
||
| 76 | ->end() |
||
| 77 | ->scalarNode('class')->defaultValue(BaseService::class)->end() |
||
| 78 | ->arrayNode('arguments')->canBeDisabled()->end() |
||
| 79 | ->end() |
||
| 80 | ->end() |
||
| 81 | ->end() |
||
| 82 | ->end() |
||
| 83 | ; |
||
| 84 | |||
| 85 | return $tree; |
||
| 86 | } |
||
| 87 | } |