Completed
Push — 0.4.x ( 61ba4f )
by Dmitry
15:42 queued 15:37
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 1
c 2
b 1
f 1
lcom 0
cbo 3
dl 0
loc 101
ccs 82
cts 82
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 93 1
1
<?php
2
3
namespace Krtv\Bundle\SingleSignOnServiceProviderBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * Class Configuration
10
 * @package Krtv\Bundle\SingleSignOnServiceProviderBundle\DependencyInjection
11
 */
12
class Configuration implements ConfigurationInterface
13
{
14
    /**
15
     * Generates the configuration tree builder.
16
     *
17
     * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
18
     */
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