| Conditions | 7 |
| Paths | 1 |
| Total Lines | 66 |
| Code Lines | 55 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 24 | public function getConfigTreeBuilder() |
||
| 25 | { |
||
| 26 | $treeBuilder = new TreeBuilder(); |
||
| 27 | $rootNode = $treeBuilder->root('httplug'); |
||
| 28 | |||
| 29 | $this->configureClients($rootNode); |
||
| 30 | |||
| 31 | $rootNode |
||
| 32 | ->validate() |
||
| 33 | ->ifTrue(function ($v) { |
||
| 34 | return !empty($v['classes']['client']) |
||
| 35 | || !empty($v['classes']['message_factory']) |
||
| 36 | || !empty($v['classes']['uri_factory']) |
||
| 37 | || !empty($v['classes']['stream_factory']); |
||
| 38 | }) |
||
| 39 | ->then(function ($v) { |
||
| 40 | foreach ($v['classes'] as $key => $class) { |
||
| 41 | if (null !== $class && !class_exists($class)) { |
||
| 42 | throw new InvalidConfigurationException(sprintf( |
||
| 43 | 'Class %s specified for httplug.classes.%s does not exist.', |
||
| 44 | $class, |
||
| 45 | $key |
||
| 46 | )); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | return $v; |
||
| 51 | }) |
||
| 52 | ->end() |
||
| 53 | ->children() |
||
| 54 | ->arrayNode('main_alias') |
||
| 55 | ->addDefaultsIfNotSet() |
||
| 56 | ->info('Configure which service the main alias point to.') |
||
| 57 | ->children() |
||
| 58 | ->scalarNode('client')->defaultValue('httplug.client.default')->end() |
||
| 59 | ->scalarNode('message_factory')->defaultValue('httplug.message_factory.default')->end() |
||
| 60 | ->scalarNode('uri_factory')->defaultValue('httplug.uri_factory.default')->end() |
||
| 61 | ->scalarNode('stream_factory')->defaultValue('httplug.stream_factory.default')->end() |
||
| 62 | ->end() |
||
| 63 | ->end() |
||
| 64 | ->arrayNode('classes') |
||
| 65 | ->addDefaultsIfNotSet() |
||
| 66 | ->info('Overwrite a service class instead of using the discovery mechanism.') |
||
| 67 | ->children() |
||
| 68 | ->scalarNode('client')->defaultNull()->end() |
||
| 69 | ->scalarNode('message_factory')->defaultNull()->end() |
||
| 70 | ->scalarNode('uri_factory')->defaultNull()->end() |
||
| 71 | ->scalarNode('stream_factory')->defaultNull()->end() |
||
| 72 | ->end() |
||
| 73 | ->end() |
||
| 74 | ->arrayNode('toolbar') |
||
| 75 | ->addDefaultsIfNotSet() |
||
| 76 | ->info('Extend the debug profiler with inforation about requests.') |
||
| 77 | ->children() |
||
| 78 | ->enumNode('enabled') |
||
| 79 | ->info('If "auto" (default), the toolbar is activated when kernel.debug is true. You can force the toolbar on and off by changing this option.') |
||
| 80 | ->values([true, false, 'auto']) |
||
| 81 | ->defaultValue('auto') |
||
| 82 | ->end() |
||
| 83 | ->scalarNode('formatter')->defaultNull()->end() |
||
| 84 | ->end() |
||
| 85 | ->end() |
||
| 86 | ->end(); |
||
| 87 | |||
| 88 | return $treeBuilder; |
||
| 89 | } |
||
| 90 | |||
| 112 |