Completed
Pull Request — develop (#198)
by
unknown
03:17
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 32
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
c 0
b 0
f 0
rs 8.8571
cc 2
eloc 26
nc 1
nop 0
1
<?php
2
3
/**
4
 * Copyright 2014 SURFnet bv
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace Surfnet\StepupMiddleware\MiddlewareBundle\DependencyInjection;
20
21
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
22
use Symfony\Component\Config\Definition\ConfigurationInterface;
23
24
class Configuration implements ConfigurationInterface
25
{
26
    public function getConfigTreeBuilder()
27
    {
28
        $treeBuilder = new TreeBuilder();
29
30
        $treeBuilder
31
            ->root('surfnet_stepup_middleware_middleware')
32
                ->children()
33
                    ->scalarNode('email_verification_window')
34
                        ->info('The amount of seconds after which the email verification url/code expires')
35
                        ->defaultValue(3600)
36
                        ->validate()
37
                            ->ifTrue(function ($seconds) {
38
                                return !is_int($seconds) || $seconds < 1;
39
                            })
40
                            ->thenInvalid(
41
                                'The email verification window must be a positive integer'
42
                            )
43
                        ->end()
44
                    ->end()
45
                    ->arrayNode('enabled_generic_second_factors')
46
                        ->isRequired()
47
                        ->prototype('array')
48
                        ->children()
49
                            ->scalarNode('loa')
50
                            ->isRequired()
51
                            ->info('The lao level of the Gssf')
52
                        ->end()
53
                    ->end()
54
                ->end();
55
56
        return $treeBuilder;
57
    }
58
}
59