| Conditions | 1 |
| Paths | 1 |
| Total Lines | 71 |
| Code Lines | 62 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| 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 |
||
| 32 | public function getConfigTreeBuilder() |
||
| 33 | { |
||
| 34 | $treeBuilder = new TreeBuilder; |
||
| 35 | |||
| 36 | $rootNode = $treeBuilder->root('surfnet_bundle'); |
||
| 37 | $rootNode |
||
| 38 | ->children() |
||
| 39 | ->arrayNode('logging') |
||
| 40 | ->isRequired() |
||
| 41 | ->children() |
||
| 42 | ->scalarNode('application_name') |
||
| 43 | ->info('This is the application name that is included with each log message') |
||
| 44 | ->isRequired() |
||
| 45 | ->validate() |
||
| 46 | ->ifTrue(function ($name) { |
||
| 47 | return !is_string($name); |
||
| 48 | }) |
||
| 49 | ->thenInvalid('surfnet_bundle.logging.application_name must be string') |
||
| 50 | ->end() |
||
| 51 | ->end() |
||
| 52 | ->end() |
||
| 53 | ->end() |
||
| 54 | ->arrayNode('loa_definition') |
||
| 55 | ->children() |
||
| 56 | ->scalarNode('loa1') |
||
| 57 | ->example('https://gateway.tld/authentication/loa1') |
||
| 58 | ->isRequired() |
||
| 59 | ->validate() |
||
| 60 | ->ifTrue(function ($value) { |
||
| 61 | return !is_string($value); |
||
| 62 | }) |
||
| 63 | ->thenInvalid('Loa definition for "loa1" must be a string') |
||
| 64 | ->end() |
||
| 65 | ->end() |
||
| 66 | ->scalarNode('loa2') |
||
| 67 | ->example('https://gateway.tld/authentication/loa2') |
||
| 68 | ->isRequired() |
||
| 69 | ->validate() |
||
| 70 | ->ifTrue(function ($value) { |
||
| 71 | return !is_string($value); |
||
| 72 | }) |
||
| 73 | ->thenInvalid('Loa definition for "loa2" must be a string') |
||
| 74 | ->end() |
||
| 75 | ->end() |
||
| 76 | ->scalarNode('loa3') |
||
| 77 | ->example('https://gateway.tld/authentication/loa3') |
||
| 78 | ->isRequired() |
||
| 79 | ->validate() |
||
| 80 | ->ifTrue(function ($value) { |
||
| 81 | return !is_string($value); |
||
| 82 | }) |
||
| 83 | ->thenInvalid('Loa definition for "loa3" must be a string') |
||
| 84 | ->end() |
||
| 85 | ->end() |
||
| 86 | ->end() |
||
| 87 | ->end() |
||
| 88 | ->arrayNode('attach_request_id_injector_to') |
||
| 89 | ->prototype('scalar') |
||
| 90 | ->validate() |
||
| 91 | ->ifTrue(function ($serviceId) { return !is_string($serviceId); }) |
||
| 92 | ->thenInvalid('surfnet_bundle.attach_request_id_injector_to must be array of strings') |
||
| 93 | ->end() |
||
| 94 | ->end() |
||
| 95 | ->end(); |
||
| 96 | |||
| 97 | $this->createGatewayApiConfiguration($rootNode); |
||
| 98 | $this->createSmsConfiguration($rootNode); |
||
| 99 | $this->createLocaleCookieConfiguration($rootNode); |
||
| 100 | |||
| 101 | return $treeBuilder; |
||
| 102 | } |
||
| 103 | |||
| 256 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.