| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 45 |
| CRAP Score | 1 |
| Changes | 4 | ||
| Bugs | 1 | Features | 2 |
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_identity_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 | ->scalarNode('logout_path') |
|
| 44 | 1 | ->isRequired() |
|
| 45 | 1 | ->end() |
|
| 46 | |||
| 47 | 1 | ->arrayNode('services') |
|
| 48 | 1 | ->info('Array of enabled ServiceProviders (SPs)') |
|
| 49 | 1 | ->isRequired() |
|
| 50 | 1 | ->prototype('scalar') |
|
| 51 | |||
| 52 | 1 | ->end() |
|
| 53 | 1 | ->end() |
|
| 54 | |||
| 55 | 1 | ->scalarNode('otp_parameter') |
|
| 56 | 1 | ->defaultValue('_otp') |
|
| 57 | 1 | ->end() |
|
| 58 | |||
| 59 | 1 | ->scalarNode('secret_parameter') |
|
| 60 | 1 | ->defaultValue('secret') |
|
| 61 | 1 | ->end() |
|
| 62 | |||
| 63 | 1 | ->scalarNode('target_path_parameter') |
|
| 64 | 1 | ->defaultValue('_target_path') |
|
| 65 | 1 | ->end() |
|
| 66 | |||
| 67 | 1 | ->scalarNode('service_parameter') |
|
| 68 | 1 | ->defaultValue('service') |
|
| 69 | 1 | ->end() |
|
| 70 | |||
| 71 | 1 | ->scalarNode('service_extra_parameter') |
|
| 72 | 1 | ->defaultValue('service_extra') |
|
| 73 | 1 | ->end() |
|
| 74 | 1 | ->end() |
|
| 75 | ; |
||
| 76 | |||
| 77 | 1 | return $builder; |
|
| 78 | } |
||
| 79 | } |
||
| 80 |