| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 46 |
| CRAP Score | 1 |
| Changes | 1 | ||
| 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 | 14 | public function getConfigTreeBuilder() |
|
| 17 | { |
||
| 18 | 14 | $builder = new TreeBuilder(); |
|
| 19 | |||
| 20 | $builder |
||
| 21 | 14 | ->root('alchemy_rest') |
|
| 22 | 14 | ->children() |
|
| 23 | 14 | ->arrayNode('exceptions') |
|
| 24 | 14 | ->addDefaultsIfNotSet() |
|
| 25 | 14 | ->children() |
|
| 26 | 14 | ->arrayNode('content_types') |
|
| 27 | 14 | ->fixXmlConfig('content_type') |
|
| 28 | 14 | ->addDefaultChildrenIfNoneSet() |
|
| 29 | 14 | ->prototype('scalar') |
|
| 30 | 14 | ->defaultValue('application/json') |
|
| 31 | 14 | ->end() |
|
| 32 | 14 | ->end() |
|
| 33 | 14 | ->scalarNode('enabled')->defaultTrue()->end() |
|
| 34 | 14 | ->scalarNode('transformer')->defaultNull()->end() |
|
| 35 | 14 | ->end() |
|
| 36 | 14 | ->end() |
|
| 37 | 14 | ->arrayNode('dates') |
|
| 38 | 14 | ->addDefaultsIfNotSet() |
|
| 39 | 14 | ->children() |
|
| 40 | 14 | ->scalarNode('enabled')->defaultTrue()->end() |
|
| 41 | 14 | ->scalarNode('format')->defaultValue('Y-m-d H:i:s')->end() |
|
| 42 | 14 | ->scalarNode('timezone')->defaultValue('UTC')->end() |
|
| 43 | 14 | ->end() |
|
| 44 | 14 | ->end() |
|
| 45 | 14 | ->arrayNode('pagination') |
|
| 46 | 14 | ->addDefaultsIfNotSet() |
|
| 47 | 14 | ->children() |
|
| 48 | 14 | ->scalarNode('enabled')->defaultTrue()->end() |
|
| 49 | 14 | ->scalarNode('limit_parameter')->defaultValue('limit')->end() |
|
| 50 | 14 | ->scalarNode('offset_parameter')->defaultValue('offset')->end() |
|
| 51 | 14 | ->end() |
|
| 52 | 14 | ->end() |
|
| 53 | 14 | ->arrayNode('sort') |
|
| 54 | 14 | ->addDefaultsIfNotSet() |
|
| 55 | 14 | ->children() |
|
| 56 | 14 | ->scalarNode('enabled')->defaultTrue()->end() |
|
| 57 | 14 | ->scalarNode('sort_parameter')->defaultValue('sort')->end() |
|
| 58 | 14 | ->scalarNode('direction_parameter')->defaultValue('dir')->end() |
|
| 59 | 14 | ->scalarNode('multi_sort_parameter')->defaultValue('sorts')->end() |
|
| 60 | 14 | ->end() |
|
| 61 | 14 | ->end() |
|
| 62 | 14 | ->end() |
|
| 63 | 14 | ->end(); |
|
| 64 | |||
| 65 | 14 | return $builder; |
|
| 66 | } |
||
| 67 | } |
||
| 68 |