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