Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 53
ccs 41
cts 41
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 47 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Rest\ClientBundle\DependencyInjection;
5
6
use Symfony\Component\Config\Definition\{
7
    Builder\TreeBuilder,
8
    ConfigurationInterface
9
};
10
use Psr\Log\LogLevel;
11
12
final class Configuration implements ConfigurationInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 5
    public function getConfigTreeBuilder()
18
    {
19 5
        $treeBuilder = new TreeBuilder;
20 5
        $root = $treeBuilder->root('innmind_rest_client');
21
22
        $root
23 5
            ->children()
24 5
                ->arrayNode('types')
25 5
                    ->defaultValue([])
26 5
                    ->prototype('scalar')->end()
27 5
                ->end()
28 5
                ->scalarNode('log_level')
29 5
                    ->info('Log level to be used to log all request sent')
30 5
                    ->validate()
31 5
                    ->ifNotInArray([
32 5
                        LogLevel::EMERGENCY,
33 5
                        LogLevel::ALERT,
34 5
                        LogLevel::CRITICAL,
35 5
                        LogLevel::ERROR,
36 5
                        LogLevel::WARNING,
37 5
                        LogLevel::NOTICE,
38 5
                        LogLevel::INFO,
39 5
                        LogLevel::DEBUG,
40
                    ])
41 5
                        ->thenInvalid('Invalid log level (check Psr\Log\LogLevel)')
42 5
                    ->end()
43 5
                ->end()
44 5
                ->scalarNode('cache_directory')->end()
45 5
                ->arrayNode('content_type')
46 5
                    ->info('The list of formats you accept in the "Content-Type" response header')
47 5
                    ->useAttributeAsKey('name')
48 5
                    ->requiresAtLeastOneElement()
49 5
                    ->prototype('array')
50 5
                        ->children()
51 5
                            ->integerNode('priority')->end()
52 5
                            ->arrayNode('media_types')
53 5
                                ->useAttributeAsKey('name')
54 5
                                ->requiresAtLeastOneElement()
55 5
                                ->prototype('scalar')->end()
56 5
                            ->end()
57 5
                        ->end()
58 5
                    ->end()
59 5
                ->end()
60 5
            ->end();
61
62 5
        return $treeBuilder;
63
    }
64
}
65