Conditions | 1 |
Paths | 1 |
Total Lines | 93 |
Code Lines | 81 |
Lines | 0 |
Ratio | 0 % |
Tests | 82 |
CRAP Score | 1 |
Changes | 2 | ||
Bugs | 1 | 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 |
||
19 | 1 | public function getConfigTreeBuilder() |
|
20 | { |
||
21 | 1 | $builder = new TreeBuilder(); |
|
22 | |||
23 | 1 | $builder->root('krtv_single_sign_on_service_provider') |
|
24 | 1 | ->children() |
|
25 | 1 | ->scalarNode('host') |
|
26 | 1 | ->isRequired() |
|
27 | 1 | ->validate() |
|
28 | 1 | ->ifTrue(function($v) { |
|
29 | 1 | return preg_match('/^http(s?):\/\//', $v); |
|
30 | 1 | }) |
|
31 | 1 | ->thenInvalid('SSO host must only contain the host, and not the url scheme, eg: idp.domain.com') |
|
32 | 1 | ->end() |
|
33 | 1 | ->end() |
|
34 | |||
35 | 1 | ->scalarNode('host_scheme') |
|
36 | 1 | ->defaultValue('http') |
|
37 | 1 | ->end() |
|
38 | |||
39 | 1 | ->scalarNode('login_path') |
|
40 | 1 | ->isRequired() |
|
41 | 1 | ->end() |
|
42 | |||
43 | 1 | ->arrayNode('otp_manager') |
|
44 | 1 | ->addDefaultsIfNotSet() |
|
45 | 1 | ->info('Configuration for OTP managers') |
|
46 | 1 | ->children() |
|
47 | 1 | ->scalarNode('name') |
|
48 | 1 | ->defaultValue('orm') |
|
49 | 1 | ->end() |
|
50 | |||
51 | 1 | ->arrayNode('managers') |
|
52 | 1 | ->addDefaultsIfNotSet() |
|
53 | 1 | ->children() |
|
54 | 1 | ->arrayNode('orm') |
|
55 | 1 | ->addDefaultsIfNotSet() |
|
56 | 1 | ->info('ORM OTP configuration') |
|
57 | 1 | ->children() |
|
58 | 1 | ->end() |
|
59 | 1 | ->end() |
|
60 | 1 | ->arrayNode('http') |
|
61 | 1 | ->addDefaultsIfNotSet() |
|
62 | 1 | ->info('HTTP OTP configuration') |
|
63 | 1 | ->children() |
|
64 | 1 | ->scalarNode('provider') |
|
65 | 1 | ->info('Active provider for HTTP OTP manager') |
|
66 | 1 | ->defaultValue('guzzle') |
|
67 | 1 | ->end() |
|
68 | 1 | ->arrayNode('providers') |
|
69 | 1 | ->addDefaultsIfNotSet() |
|
70 | 1 | ->info('Available HTTP providers') |
|
71 | 1 | ->children() |
|
72 | 1 | ->arrayNode('guzzle') |
|
73 | 1 | ->addDefaultsIfNotSet() |
|
74 | 1 | ->children() |
|
75 | 1 | ->scalarNode('client') |
|
76 | 1 | ->info('Guzzle client service id') |
|
77 | 1 | ->end() |
|
78 | 1 | ->scalarNode('resource') |
|
79 | 1 | ->info('Url for fetch/invalidate OTPs') |
|
80 | 1 | ->end() |
|
81 | 1 | ->end() |
|
82 | 1 | ->end() |
|
83 | 1 | ->arrayNode('service') |
|
84 | 1 | ->addDefaultsIfNotSet() |
|
85 | 1 | ->children() |
|
86 | 1 | ->scalarNode('id') |
|
87 | 1 | ->info('Service id') |
|
88 | 1 | ->end() |
|
89 | 1 | ->end() |
|
90 | 1 | ->end() |
|
91 | 1 | ->end() |
|
92 | 1 | ->end() |
|
93 | 1 | ->end() |
|
94 | 1 | ->end() |
|
95 | 1 | ->end() |
|
96 | 1 | ->end() |
|
97 | 1 | ->end() |
|
98 | 1 | ->end() |
|
99 | |||
100 | 1 | ->scalarNode('otp_parameter') |
|
101 | 1 | ->defaultValue('_otp') |
|
102 | 1 | ->end() |
|
103 | |||
104 | 1 | ->scalarNode('secret_parameter') |
|
105 | 1 | ->defaultValue('secret') |
|
106 | 1 | ->end() |
|
107 | 1 | ->end() |
|
108 | ; |
||
109 | |||
110 | 1 | return $builder; |
|
111 | } |
||
112 | } |
||
113 |