| Conditions | 1 |
| Paths | 1 |
| Total Lines | 85 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 76 |
| CRAP Score | 1 |
| 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 |
||
| 30 | 1 | public function getConfigTreeBuilder() |
|
| 31 | { |
||
| 32 | 1 | $treeBuilder = new TreeBuilder(); |
|
| 33 | 1 | $rootNode = $treeBuilder->root('gearman'); |
|
| 34 | |||
| 35 | $rootNode |
||
| 36 | 1 | ->children() |
|
| 37 | 1 | ->arrayNode('bundles') |
|
| 38 | 1 | ->prototype('array') |
|
| 39 | 1 | ->children() |
|
| 40 | 1 | ->scalarNode('name') |
|
| 41 | 1 | ->isRequired() |
|
| 42 | 1 | ->cannotBeEmpty() |
|
| 43 | 1 | ->end() |
|
| 44 | 1 | ->booleanNode('active') |
|
| 45 | 1 | ->defaultFalse() |
|
| 46 | 1 | ->end() |
|
| 47 | 1 | ->arrayNode('include') |
|
| 48 | 1 | ->prototype('scalar')->end() |
|
| 49 | 1 | ->end() |
|
| 50 | 1 | ->arrayNode('ignore') |
|
| 51 | 1 | ->prototype('scalar')->end() |
|
| 52 | 1 | ->end() |
|
| 53 | 1 | ->end() |
|
| 54 | 1 | ->end() |
|
| 55 | 1 | ->end() |
|
| 56 | 1 | ->arrayNode('resources') |
|
| 57 | 1 | ->scalarPrototype()->end() |
|
| 58 | 1 | ->end() |
|
| 59 | 1 | ->arrayNode('servers') |
|
| 60 | 1 | ->performNoDeepMerging() |
|
| 61 | 1 | ->defaultValue(array( |
|
| 62 | 1 | 'localhost' => array( |
|
| 63 | 'host' => '127.0.0.1', |
||
| 64 | 'port' => '4730', |
||
| 65 | ), |
||
| 66 | )) |
||
| 67 | 1 | ->prototype('array') |
|
| 68 | 1 | ->children() |
|
| 69 | 1 | ->scalarNode('host') |
|
| 70 | 1 | ->isRequired() |
|
| 71 | 1 | ->cannotBeEmpty() |
|
| 72 | 1 | ->end() |
|
| 73 | 1 | ->integerNode('port') |
|
| 74 | 1 | ->defaultValue('4730') |
|
| 75 | 1 | ->end() |
|
| 76 | 1 | ->end() |
|
| 77 | 1 | ->end() |
|
| 78 | 1 | ->end() |
|
| 79 | 1 | ->arrayNode('defaults') |
|
| 80 | 1 | ->addDefaultsIfNotSet() |
|
| 81 | 1 | ->children() |
|
| 82 | 1 | ->integerNode('iterations') |
|
| 83 | 1 | ->min(0) |
|
| 84 | 1 | ->defaultValue(0) |
|
| 85 | 1 | ->end() |
|
| 86 | 1 | ->scalarNode('method') |
|
| 87 | 1 | ->defaultValue('doNormal') |
|
| 88 | 1 | ->end() |
|
| 89 | 1 | ->booleanNode('callbacks') |
|
| 90 | 1 | ->defaultTrue() |
|
| 91 | 1 | ->end() |
|
| 92 | 1 | ->scalarNode('job_prefix') |
|
| 93 | 1 | ->defaultNull() |
|
| 94 | 1 | ->end() |
|
| 95 | 1 | ->booleanNode('generate_unique_key') |
|
| 96 | 1 | ->defaultTrue() |
|
| 97 | 1 | ->end() |
|
| 98 | 1 | ->booleanNode('workers_name_prepend_namespace') |
|
| 99 | 1 | ->defaultTrue() |
|
| 100 | 1 | ->end() |
|
| 101 | 1 | ->integerNode('minimum_execution_time') |
|
| 102 | 1 | ->min(0) |
|
| 103 | 1 | ->defaultValue(0) |
|
| 104 | 1 | ->end() |
|
| 105 | 1 | ->integerNode('timeout') |
|
| 106 | 1 | ->min(0) |
|
| 107 | 1 | ->defaultValue(0) |
|
| 108 | 1 | ->end() |
|
| 109 | 1 | ->end() |
|
| 110 | 1 | ->end() |
|
| 111 | 1 | ->end(); |
|
| 112 | |||
| 113 | 1 | return $treeBuilder; |
|
| 114 | } |
||
| 115 | } |
||
| 116 |