Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 9.504
c 0
b 0
f 0
cc 2
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\StepupU2fBundle\DependencyInjection;
20
21
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
22
use Symfony\Component\Config\Definition\ConfigurationInterface;
23
24
/**
25
 * @codeCoverageIgnore
26
 */
27
class Configuration implements ConfigurationInterface
28
{
29
    public function getConfigTreeBuilder()
30
    {
31
        $treeBuilder = new TreeBuilder('surfnet_stepup_u2f');
32
33
        $rootNode = $treeBuilder->getRootNode();
34
        $rootNode
35
            ->children()
36
                ->scalarNode('app_id')
37
                    ->info(
38
                        'This is the URL that identifies this logical application and from where the Trusted Facets ' .
39
                        'List is served'
40
                    )
41
                    ->isRequired()
42
                    ->validate()
43
                        ->ifTrue(
44
                            function ($appId) {
45
                                return !is_string($appId) || parse_url($appId, PHP_URL_SCHEME) !== 'https';
46
                            }
47
                        )
48
                        ->thenInvalid('surfnet_stepup_u2f.app_id must be an HTTPS URL')
49
                    ->end()
50
                ->end()
51
            ->end();
52
53
        return $treeBuilder;
54
    }
55
}
56