| Conditions | 1 |
| Paths | 1 |
| Total Lines | 62 |
| Code Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 11 | ||
| Bugs | 3 | 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 declare(strict_types=1); |
||
| 22 | public function getConfigTreeBuilder() |
||
| 23 | { |
||
| 24 | $treeBuilder = new TreeBuilder(); |
||
| 25 | $rootNode = $treeBuilder->root('swagger'); |
||
| 26 | |||
| 27 | $rootNode |
||
| 28 | ->children() |
||
| 29 | ->arrayNode('errors') |
||
| 30 | ->addDefaultsIfNotSet() |
||
| 31 | ->children() |
||
| 32 | ->scalarNode('strategy') |
||
| 33 | ->defaultValue('simple') |
||
| 34 | ->cannotBeEmpty() |
||
| 35 | ->info('Strategy name or error response factory DI key') |
||
| 36 | ->end() |
||
| 37 | ->scalarNode('logref_builder') |
||
| 38 | ->defaultValue('uniqid') |
||
| 39 | ->cannotBeEmpty() |
||
| 40 | ->info('Strategy name or error response factory DI key') |
||
| 41 | ->end() |
||
| 42 | ->end() |
||
| 43 | ->end() |
||
| 44 | |||
| 45 | ->arrayNode('serializer') |
||
| 46 | ->addDefaultsIfNotSet() |
||
| 47 | ->children() |
||
| 48 | ->enumNode('type') |
||
| 49 | ->values(array('array', 'swagger', 'jms', 'symfony')) |
||
| 50 | ->defaultValue('array') |
||
| 51 | ->cannotBeEmpty() |
||
| 52 | ->end() |
||
| 53 | ->arrayNode('namespace') |
||
| 54 | ->beforeNormalization() |
||
| 55 | ->ifString() |
||
| 56 | ->then(function ($v) { |
||
| 57 | return [$v]; |
||
| 58 | }) |
||
| 59 | ->end() |
||
| 60 | ->prototype('scalar') |
||
| 61 | ->end() |
||
| 62 | ->end() |
||
| 63 | ->end() |
||
| 64 | ->end() |
||
| 65 | ->arrayNode('document') |
||
| 66 | ->addDefaultsIfNotSet() |
||
| 67 | ->children() |
||
| 68 | ->scalarNode('cache')->isRequired()->defaultFalse()->end() |
||
| 69 | ->scalarNode('base_path')->defaultValue('')->end() |
||
| 70 | ->arrayNode('public') |
||
| 71 | ->addDefaultsIfNotSet() |
||
| 72 | ->children() |
||
| 73 | ->scalarNode('scheme')->defaultNull()->end() |
||
| 74 | ->scalarNode('base_url')->defaultValue('/')->end() |
||
| 75 | ->scalarNode('host')->defaultNull()->end() |
||
| 76 | ->end() |
||
| 77 | ->end() |
||
| 78 | ->end() |
||
| 79 | ->end() |
||
| 80 | ->end() |
||
| 81 | ; |
||
| 82 | return $treeBuilder; |
||
| 83 | } |
||
| 84 | } |
||
| 85 |