Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 45 1
1
<?php
2
/*
3
 * This file is part of the FreshCentrifugoBundle.
4
 *
5
 * (c) Artem Henvald <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace Fresh\CentrifugoBundle\DependencyInjection;
14
15
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
16
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
17
use Symfony\Component\Config\Definition\ConfigurationInterface;
18
19
/**
20
 * Configuration.
21
 *
22
 * @author Artem Henvald <[email protected]>
23
 */
24
class Configuration implements ConfigurationInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getConfigTreeBuilder(): TreeBuilder
30
    {
31
        $treeBuilder = new TreeBuilder('fresh_centrifugo');
32
33
        /** @var ArrayNodeDefinition $root */
34
        $root = $treeBuilder->getRootNode();
35
36
        $root
37
            ->children()
38
                ->arrayNode('jwt')
39
                    ->addDefaultsIfNotSet()
40
                    ->children()
41
                        ->integerNode('ttl')
42
                            ->min(0)
43
                            ->defaultNull()
44
                            ->info('TTL for JWT tokens in seconds.')
45
                        ->end()
46
                    ->end()
47
                ->end()
48
                ->integerNode('channel_max_length')
49
                    ->min(1)
50
                    ->defaultValue(255)
51
                    ->info('Maximum length of channel name.')
52
                ->end()
53
                ->booleanNode('fake_mode')
54
                    ->defaultFalse()
55
                    ->info('Enables fake mode for Centrifugo client, no real request will be sent.')
56
                ->end()
57
                ->scalarNode('api_key')
58
                    ->defaultValue('%env(CENTRIFUGO_API_KEY)%')
59
                    ->info('Centrifugo API key')
60
                ->end()
61
                ->scalarNode('api_endpoint')
62
                    ->defaultValue('%env(CENTRIFUGO_API_ENDPOINT)%')
63
                    ->info('Centrifugo API endpoint')
64
                ->end()
65
                ->scalarNode('secret')
66
                    ->defaultValue('%env(CENTRIFUGO_SECRET)%')
67
                    ->info('Centrifugo secret')
68
                ->end()
69
            ->end()
70
        ;
71
72
        return $treeBuilder;
73
    }
74
}
75