| Conditions | 1 |
| Paths | 1 |
| Total Lines | 70 |
| Code Lines | 63 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 10 | public function getConfigTreeBuilder() |
||
| 11 | { |
||
| 12 | $treeBuilder = new TreeBuilder(); |
||
| 13 | $rootNode = $treeBuilder->root('loevgaard_dandomain_altapay'); |
||
| 14 | |||
| 15 | $rootNode |
||
| 16 | ->children() |
||
| 17 | ->scalarNode('altapay_username') |
||
| 18 | ->isRequired() |
||
| 19 | ->cannotBeEmpty() |
||
| 20 | ->end() |
||
| 21 | ->scalarNode('altapay_password') |
||
| 22 | ->isRequired() |
||
| 23 | ->cannotBeEmpty() |
||
| 24 | ->end() |
||
| 25 | ->arrayNode('altapay_ips') |
||
| 26 | ->isRequired() |
||
| 27 | ->requiresAtLeastOneElement() |
||
| 28 | ->prototype('scalar')->end() |
||
| 29 | ->end() |
||
| 30 | ->scalarNode('altapay_url') |
||
| 31 | ->isRequired() |
||
| 32 | ->cannotBeEmpty() |
||
| 33 | ->beforeNormalization() |
||
| 34 | ->ifString() |
||
| 35 | ->then(function ($v) { |
||
| 36 | return rtrim($v, '/'); |
||
| 37 | }) |
||
| 38 | ->end() |
||
| 39 | ->validate() |
||
| 40 | ->ifTrue(function ($v) { |
||
| 41 | return false === filter_var($v, FILTER_VALIDATE_URL); |
||
| 42 | }) |
||
| 43 | ->thenInvalid('The URL is invalid') |
||
| 44 | ->end() |
||
| 45 | ->end() |
||
| 46 | ->scalarNode('shared_key_1') |
||
| 47 | ->isRequired() |
||
| 48 | ->cannotBeEmpty() |
||
| 49 | ->end() |
||
| 50 | ->scalarNode('shared_key_2') |
||
| 51 | ->isRequired() |
||
| 52 | ->cannotBeEmpty() |
||
| 53 | ->end() |
||
| 54 | ->scalarNode('cookie_payment_id') |
||
| 55 | ->defaultValue('payment_id') |
||
| 56 | ->end() |
||
| 57 | ->scalarNode('cookie_checksum_complete') |
||
| 58 | ->defaultValue('checksum_complete') |
||
| 59 | ->end() |
||
| 60 | ->arrayNode('default_settings') |
||
| 61 | ->isRequired() |
||
| 62 | ->children() |
||
| 63 | ->arrayNode('layout') |
||
| 64 | ->isRequired() |
||
| 65 | ->children() |
||
| 66 | ->scalarNode('logo') |
||
| 67 | ->isRequired() |
||
| 68 | ->cannotBeEmpty() |
||
| 69 | ->end() |
||
| 70 | ->end() |
||
| 71 | ->end() |
||
| 72 | ->end() |
||
| 73 | ->end() |
||
| 74 | ->end() |
||
| 75 | ->fixXmlConfig('altapay_ip') |
||
| 76 | ; |
||
| 77 | |||
| 78 | return $treeBuilder; |
||
| 79 | } |
||
| 80 | } |
||
| 81 |