| Conditions | 1 |
| Paths | 1 |
| Total Lines | 119 |
| Code Lines | 115 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 114 |
| CRAP Score | 1 |
| Changes | 3 | ||
| Bugs | 0 | 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 |
||
| 16 | 16 | public function getConfigTreeBuilder() |
|
| 17 | { |
||
| 18 | 16 | $treeBuilder = new TreeBuilder; |
|
| 19 | 16 | $root = $treeBuilder->root('innmind_amqp'); |
|
| 20 | |||
| 21 | $root |
||
| 22 | 16 | ->children() |
|
| 23 | 16 | ->arrayNode('server') |
|
| 24 | 16 | ->addDefaultsIfNotSet() |
|
| 25 | 16 | ->children() |
|
| 26 | 16 | ->arrayNode('transport') |
|
| 27 | 16 | ->addDefaultsIfNotSet() |
|
| 28 | 16 | ->children() |
|
| 29 | 16 | ->scalarNode('name') |
|
| 30 | 16 | ->info('tcp, ssl, etc...') |
|
| 31 | 16 | ->defaultValue('tcp') |
|
| 32 | 16 | ->end() |
|
| 33 | 16 | ->arrayNode('options') |
|
| 34 | 16 | ->useAttributeAsKey('name') |
|
| 35 | 16 | ->prototype('variable')->end() |
|
| 36 | 16 | ->defaultValue([]) |
|
| 37 | 16 | ->end() |
|
| 38 | 16 | ->end() |
|
| 39 | 16 | ->end() |
|
| 40 | 16 | ->scalarNode('host') |
|
| 41 | 16 | ->defaultValue('localhost') |
|
| 42 | 16 | ->end() |
|
| 43 | 16 | ->integerNode('port') |
|
| 44 | 16 | ->defaultValue(5672) |
|
| 45 | 16 | ->end() |
|
| 46 | 16 | ->scalarNode('user') |
|
| 47 | 16 | ->defaultValue('guest') |
|
| 48 | 16 | ->end() |
|
| 49 | 16 | ->scalarNode('password') |
|
| 50 | 16 | ->defaultValue('guest') |
|
| 51 | 16 | ->end() |
|
| 52 | 16 | ->scalarNode('vhost') |
|
| 53 | 16 | ->defaultValue('/') |
|
| 54 | 16 | ->end() |
|
| 55 | 16 | ->integerNode('timeout') |
|
| 56 | 16 | ->info('Expressed in milliseconds') |
|
| 57 | 16 | ->defaultValue(60000) |
|
| 58 | 16 | ->end() |
|
| 59 | 16 | ->end() |
|
| 60 | 16 | ->end() |
|
| 61 | 16 | ->arrayNode('exchanges') |
|
| 62 | 16 | ->useAttributeAsKey('name') |
|
| 63 | 16 | ->prototype('array') |
|
| 64 | 16 | ->children() |
|
| 65 | 16 | ->enumNode('type') |
|
| 66 | 16 | ->isRequired() |
|
| 67 | 16 | ->values(['direct', 'fanout', 'topic', 'headers']) |
|
| 68 | 16 | ->end() |
|
| 69 | 16 | ->booleanNode('durable') |
|
| 70 | 16 | ->defaultValue(true) |
|
| 71 | 16 | ->end() |
|
| 72 | 16 | ->arrayNode('arguments') |
|
| 73 | 16 | ->useAttributeAsKey('name') |
|
| 74 | 16 | ->prototype('variable')->end() |
|
| 75 | 16 | ->end() |
|
| 76 | 16 | ->end() |
|
| 77 | 16 | ->end() |
|
| 78 | 16 | ->end() |
|
| 79 | 16 | ->arrayNode('queues') |
|
| 80 | 16 | ->useAttributeAsKey('name') |
|
| 81 | 16 | ->prototype('array') |
|
| 82 | 16 | ->children() |
|
| 83 | 16 | ->booleanNode('durable') |
|
| 84 | 16 | ->defaultValue(true) |
|
| 85 | 16 | ->end() |
|
| 86 | 16 | ->booleanNode('exclusive') |
|
| 87 | 16 | ->defaultValue(false) |
|
| 88 | 16 | ->end() |
|
| 89 | 16 | ->arrayNode('arguments') |
|
| 90 | 16 | ->useAttributeAsKey('name') |
|
| 91 | 16 | ->prototype('variable')->end() |
|
| 92 | 16 | ->end() |
|
| 93 | 16 | ->scalarNode('consumer') |
|
| 94 | 16 | ->info('Service id that will consume messages') |
|
| 95 | 16 | ->isRequired() |
|
| 96 | 16 | ->end() |
|
| 97 | 16 | ->end() |
|
| 98 | 16 | ->end() |
|
| 99 | 16 | ->end() |
|
| 100 | 16 | ->arrayNode('bindings') |
|
| 101 | 16 | ->prototype('array') |
|
| 102 | 16 | ->children() |
|
| 103 | 16 | ->scalarNode('exchange') |
|
| 104 | 16 | ->isRequired() |
|
| 105 | 16 | ->end() |
|
| 106 | 16 | ->scalarNode('queue') |
|
| 107 | 16 | ->isRequired() |
|
| 108 | 16 | ->end() |
|
| 109 | 16 | ->scalarNode('routingKey') |
|
| 110 | 16 | ->defaultValue('') |
|
| 111 | 16 | ->end() |
|
| 112 | 16 | ->arrayNode('arguments') |
|
| 113 | 16 | ->useAttributeAsKey('name') |
|
| 114 | 16 | ->prototype('variable')->end() |
|
| 115 | 16 | ->end() |
|
| 116 | 16 | ->end() |
|
| 117 | 16 | ->end() |
|
| 118 | 16 | ->end() |
|
| 119 | 16 | ->arrayNode('argument_translators') |
|
| 120 | 16 | ->prototype('scalar') |
|
| 121 | 16 | ->info('List of service ids implementing ArgumentTranslator') |
|
| 122 | 16 | ->end() |
|
| 123 | 16 | ->end() |
|
| 124 | 16 | ->scalarNode('clock') |
|
| 125 | 16 | ->info('Service id of the clock to use') |
|
| 126 | 16 | ->defaultValue('innmind.amqp.clock') |
|
| 127 | 16 | ->end() |
|
| 128 | 16 | ->booleanNode('handle_posix_signals') |
|
| 129 | 16 | ->defaultValue(true) |
|
| 130 | 16 | ->end() |
|
| 131 | 16 | ->end(); |
|
| 132 | |||
| 133 | 16 | return $treeBuilder; |
|
| 134 | } |
||
| 135 | } |
||
| 136 |