Completed
Push — master ( 2aa80c...f80030 )
by Alexandru
08:43
created

Configuration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B getConfigTreeBuilder() 0 38 1
1
<?php
2
3
/*
4
 * This file is part of the Arkitekto\RequestId library.
5
 *
6
 * (c) Alexandru Furculita <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.md.
10
 */
11
12
namespace Arki\RequestId\Integrations\Symfony\DependencyInjection;
13
14
use Arki\RequestId\RequestId;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Config\Definition\ConfigurationInterface;
17
18
final class Configuration implements ConfigurationInterface
19
{
20
    /**
21
     * @var string
22
     */
23
    private $alias;
24
25
    /**
26
     * @param string $alias
27
     */
28
    public function __construct($alias)
29
    {
30
        $this->alias = $alias;
31
    }
32
33
    /**
34
     * Generates the configuration tree builder.
35
     *
36
     * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
37
     */
38
    public function getConfigTreeBuilder()
39
    {
40
        $tree = new TreeBuilder();
41
        $root = $tree->root($this->alias);
42
43
        $root
44
            ->children()
45
                ->scalarNode('request_header')
46
                    ->cannotBeEmpty()
47
                    ->defaultValue(RequestId::HEADER_NAME)
48
                    ->info('The header in which the bundle will look for and set request IDs')
49
                ->end()
50
                ->booleanNode('trust_request_header')
51
                    ->defaultValue(true)
52
                    ->info("Whether or not to trust the incoming request's `Request-Id` header as a real ID")
53
                ->end()
54
                ->scalarNode('response_header')
55
                    ->cannotBeEmpty()
56
                    ->defaultValue('Request-Id')
57
                    ->info('The header the bundle will set the request ID at in the response')
58
                ->end()
59
                ->scalarNode('storage_service')
60
                    ->info('The service name for request ID storage. Defaults to `SimpleIdStorage`')
61
                ->end()
62
                ->scalarNode('generator_service')
63
                    ->info('The service name for the request ID generator. Defaults to `Uuid4IdGenerator`')
64
                ->end()
65
                ->booleanNode('enable_monolog')
66
                    ->info('Whether or not to turn on the request ID processor for monolog')
67
                    ->defaultTrue()
68
                ->end()
69
                ->booleanNode('enable_twig')
70
                    ->info('Whether or not to enable the twig `request_id()` function. Only works if TwigBundle is present.')
71
                    ->defaultTrue()
72
                ->end();
73
74
        return $tree;
75
    }
76
}
77