Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 40 2
1
<?php
2
3
/*
4
 * This file is part of the "elao/api-resources-metadata" package.
5
 *
6
 * Copyright (C) 2016 Elao
7
 *
8
 * @author Elao <[email protected]>
9
 */
10
11
namespace Elao\ApiResourcesMetadata\Bridge\Symfony\Bundle\DependencyInjection;
12
13
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
14
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15
use Symfony\Component\Config\Definition\ConfigurationInterface;
16
use Symfony\Component\PropertyInfo;
17
18
class Configuration implements ConfigurationInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getConfigTreeBuilder()
24
    {
25
        $treeBuilder = new TreeBuilder();
26
        $root = $treeBuilder->root('elao_api_resources_metadata');
27
28
        $root
29
            ->children()
30
                ->booleanNode('nelmio_api_doc')->defaultValue(class_exists(NelmioApiDocBundle::class))->end()
31
                ->scalarNode('cache')->info('true, false or cache service id')->end()
32
                // loaders
33
                ->arrayNode('loaders')
34
                    ->addDefaultsIfNotSet()
35
                    ->children()
36
                        ->arrayNode('yaml')
37
                            ->canBeDisabled()
38
                            ->children()
39
                                ->scalarNode('path')
40
                                    ->defaultValue('%kernel.root_dir%/Resources/api_resources_metadata.yml')
41
                                ->end()
42
                            ->end()
43
                        ->end()
44
                        ->arrayNode('property_info')
45
                            ->{class_exists(PropertyInfo\Type::class) ? 'canBeDisabled' : 'canBeEnabled'}()
46
                            ->children()
47
                                ->scalarNode('service')
48
                                    ->defaultValue('elao.api_resources_metadata.property_info')
49
                                ->end()
50
                            ->end()
51
                        ->end()
52
                    ->end()
53
                ->end()
54
                // resources for array locator
55
                ->arrayNode('resources')
56
                    ->useAttributeAsKey('shortName')->prototype('scalar')->end()
57
                ->end()
58
            ->end()
59
        ;
60
61
        return $treeBuilder;
62
    }
63
}
64