Conditions | 1 |
Paths | 1 |
Total Lines | 90 |
Code Lines | 83 |
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('webhook_urls') |
||
61 | ->scalarPrototype()->end() |
||
62 | ->end() |
||
63 | ->arrayNode('default_settings') |
||
64 | ->isRequired() |
||
65 | ->children() |
||
66 | ->arrayNode('layout') |
||
67 | ->isRequired() |
||
68 | ->children() |
||
69 | ->scalarNode('logo') |
||
70 | ->isRequired() |
||
71 | ->cannotBeEmpty() |
||
72 | ->end() |
||
73 | ->end() |
||
74 | ->end() |
||
75 | ->scalarNode('opening_days') |
||
76 | ->isRequired() |
||
77 | ->cannotBeEmpty() |
||
78 | ->end() |
||
79 | ->scalarNode('opening_hours') |
||
80 | ->isRequired() |
||
81 | ->cannotBeEmpty() |
||
82 | ->end() |
||
83 | ->scalarNode('email') |
||
84 | ->isRequired() |
||
85 | ->cannotBeEmpty() |
||
86 | ->end() |
||
87 | ->scalarNode('phone') |
||
88 | ->isRequired() |
||
89 | ->cannotBeEmpty() |
||
90 | ->end() |
||
91 | ->end() |
||
92 | ->end() |
||
93 | ->end() |
||
94 | ->fixXmlConfig('webhook_url') |
||
95 | ->fixXmlConfig('altapay_ip') |
||
96 | ; |
||
97 | |||
98 | return $treeBuilder; |
||
99 | } |
||
100 | } |
||
101 |