Completed
Pull Request — develop (#273)
by Samuel
19:01 queued 08:39
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 23 1
1
<?php
2
/**
3
 * Configuration definition to be able to define every swagger source via /app/config/config.yml
4
 */
5
6
namespace Graviton\ProxyBundle\DependencyInjection;
7
8
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
9
use Symfony\Component\Config\Definition\ConfigurationInterface;
10
11
/**
12
 * Class Configuration
13
 *
14
 * To learn more see {@link http://scm.to/00Yb}
15
 *
16
 * @author  List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
17
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
18
 * @link    http://swisscom.ch
19
 */
20
class Configuration implements ConfigurationInterface
21
{
22
    /**
23
     * Defines the structure of the configuration information.
24
     *
25
     * Example structure to be used in /app/config/config.yml:
26
     *
27
     *   graviton_proxy:
28
     *     sources:
29
     *       swagger:
30
     *         petstore:
31
     *           prefix: petstore
32
     *           uri:    http://petstore.swagger.io/v2/swagger.json
33
     *         another_source:
34
     *           prefix: myswaggerinstance
35
     *           uri:    http://swagger.example.org/swagger.json
36
     *
37
     * @return TreeBuilder
38
     */
39 1
    public function getConfigTreeBuilder()
40
    {
41 1
        $treeBuilder = new TreeBuilder();
42 1
        $rootNode = $treeBuilder->root('graviton_proxy');
43
44
        $rootNode
45 1
            ->children()
46 1
            ->arrayNode('sources')
47 1
            ->useAttributeAsKey('name')
48 1
            ->prototype('array')
49 1
            ->useAttributeAsKey('name')
50 1
            ->prototype('array')
51 1
            ->children()
52 1
            ->scalarNode('prefix')->isRequired()->cannotBeEmpty()->end()
53 1
            ->scalarNode('uri')->isRequired()->cannotBeEmpty()->end()
54 1
            ->end()
55 1
            ->end()
56 1
            ->end()
57 1
            ->end() // swagger_proxy
58 1
            ->end();
59
60 1
        return $treeBuilder;
61
    }
62
}
63