Completed
Pull Request — master (#102)
by Boy
18:16
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 52
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 52
rs 9.4929
cc 3
eloc 40
nc 1
nop 0

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
/**
4
 * Copyright 2015 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\StepupGateway\U2fVerificationBundle\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_gateway_u2f_verification')
32
            ->children()
33
                ->arrayNode('migrations')
34
                    ->addDefaultsIfNotSet()
35
                    ->children()
36
                        ->scalarNode('diff_entity_manager')
37
                            ->info(
38
                                'This is the name of the Doctrine entity manager that is used for schema ' .
39
                                'diffing. If it is unspecified, or NULL, the default entity manager is used.'
40
                            )
41
                            ->defaultNull()
42
                            ->validate()
43
                                ->ifTrue(
44
                                    function ($entityManagerName) {
45
                                        return !is_string($entityManagerName) && $entityManagerName !== null;
46
                                    }
47
                                )
48
                                ->thenInvalid(
49
                                    'surfnet_stepup_gateway_u2f_verification.migrations.diff_entity_manager should ' .
50
                                    'be a string or NULL'
51
                                )
52
                            ->end()
53
                        ->end()
54
                        ->scalarNode('migrate_entity_manager')
55
                            ->info(
56
                                'This is the name of the Doctrine entity manager that is used for migrations. ' .
57
                                'If it is unspecified, or NULL, the default entity manager is used.'
58
                            )
59
                            ->defaultNull()
60
                            ->validate()
61
                                ->ifTrue(
62
                                    function ($entityManagerName) {
63
                                        return !is_string($entityManagerName) && $entityManagerName !== null;
64
                                    }
65
                                )
66
                                ->thenInvalid(
67
                                    'surfnet_stepup_gateway_u2f_verification.migrations.migrate_entity_manager ' .
68
                                    'should be a string or NULL'
69
                                )
70
                            ->end()
71
                        ->end()
72
                    ->end()
73
                ->end()
74
            ->end();
75
76
        return $treeBuilder;
77
    }
78
}
79