Conditions | 3 |
Paths | 1 |
Total Lines | 55 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 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 |
||
29 | public function getConfigTreeBuilder() |
||
30 | { |
||
31 | $treeBuilder = new TreeBuilder(); |
||
32 | |||
33 | $rootNode = $treeBuilder->root('surfnet_stepup_gateway_gateway'); |
||
34 | |||
35 | $rootNode |
||
36 | ->children() |
||
37 | ->scalarNode('intrinsic_loa') |
||
38 | ->isRequired() |
||
39 | ->end() |
||
40 | ->arrayNode('enabled_second_factors') |
||
41 | ->isRequired() |
||
42 | ->prototype('scalar') |
||
43 | ->validate() |
||
44 | ->ifTrue(function ($type) { |
||
45 | try { |
||
46 | new SecondFactorType($type); |
||
47 | } catch (InvalidArgumentException $e) { |
||
48 | return true; |
||
49 | } catch (DomainException $e) { |
||
50 | return true; |
||
51 | } |
||
52 | }) |
||
53 | ->thenInvalid( |
||
54 | 'Enabled second factor type "%s" is not one of the valid types. See SecondFactorType' |
||
55 | ) |
||
56 | ->end() |
||
57 | ->end() |
||
58 | ->end() |
||
59 | ->arrayNode('loa_domains') |
||
60 | ->isRequired() |
||
61 | ->children() |
||
62 | ->arrayNode('gateway') |
||
63 | ->prototype('array') |
||
64 | ->children() |
||
65 | ->scalarNode('loa')->isRequired()->end() |
||
66 | ->scalarNode('ref')->isRequired()->end() |
||
67 | ->end() |
||
68 | ->end() |
||
69 | ->end() |
||
70 | ->arrayNode('second_factor_only') |
||
71 | ->prototype('array') |
||
72 | ->children() |
||
73 | ->scalarNode('loa')->isRequired()->end() |
||
74 | ->scalarNode('ref')->isRequired()->end() |
||
75 | ->end() |
||
76 | ->end() |
||
77 | ->end() |
||
78 | ->end() |
||
79 | ->end() |
||
80 | ->end(); |
||
81 | |||
82 | return $treeBuilder; |
||
83 | } |
||
84 | } |
||
85 |