Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 13 1
A getProjectNode() 0 17 1
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\PlatformAdapter\Transifex\Bridge\Symfony\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15
use Symfony\Component\Config\Definition\ConfigurationInterface;
16
17
/**
18
 * @author Tobias Nyholm <[email protected]>
19
 */
20
class Configuration implements ConfigurationInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function getConfigTreeBuilder()
26
    {
27
        $treeBuilder = new TreeBuilder();
28
        $root = $treeBuilder->root('translation_adapter_transifex');
29
30
        $root->children()
31
            ->scalarNode('username')->isRequired()->cannotBeEmpty()->end()
32
            ->scalarNode('password')->isRequired()->cannotBeEmpty()->end()
33
            ->append($this->getProjectNode())
34
        ->end();
35
36
        return $treeBuilder;
37
    }
38
39
    /**
40
     * @return \Symfony\Component\Config\Definition\Builder\NodeDefinition
41
     */
42
    private function getProjectNode()
43
    {
44
        $treeBuilder = new TreeBuilder();
45
        $node = $treeBuilder->root('projects');
46
        $node
47
            ->useAttributeAsKey('name')
48
            ->prototype('array')
49
            ->children()
50
                ->arrayNode('domains')
51
                    ->requiresAtLeastOneElement()
52
                    ->prototype('scalar')->end()
53
                ->end()
54
            ->end()
55
        ->end();
56
57
        return $node;
58
    }
59
}
60