Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 49

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 49
ccs 0
cts 35
cp 0
rs 9.1127
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dziki\MonologSentryBundle\DependencyInjection;
6
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\ConfigurationInterface;
9
10
class Configuration implements ConfigurationInterface
11
{
12
    public function getConfigTreeBuilder(): TreeBuilder
13
    {
14
        $treeBuilder = new TreeBuilder('monolog_sentry');
15
        // Forward compatibility with Symfony 4.2.
16
        // @see https://symfony.com/blog/new-in-symfony-4-2-important-deprecations
17
        $rootNode = method_exists($treeBuilder, 'getRootNode')
18
            ? $treeBuilder->getRootNode()
19
            : $treeBuilder->root('monolog_sentry');
0 ignored issues
show
Bug introduced by
The method root() does not seem to exist on object<Symfony\Component...on\Builder\TreeBuilder>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
20
21
        // @formatter:off
22
        $rootNode
23
            ->children()
24
                ->booleanNode('user_context')
25
                    ->info('whether to log or not username obtained from TokenStorage')
26
                    ->defaultFalse()
27
                ->end()
28
                ->scalarNode('user_agent_parser')
29
                    ->info('phpuseragent (default), native or id of custom service implementing ParserInterface interface')
30
                    ->defaultNull()
31
                ->end()
32
                ->scalarNode('cache')
33
                    ->info('"CacheInterface" implementing cache service ID')
34
                    ->defaultNull()
35
                ->end()
36
                ->arrayNode('tags')
37
                    ->arrayPrototype()
38
                        ->beforeNormalization()
39
                        ->ifString()
40
                        ->then(function ($value) {
41
                            return ['value' => $value];
42
                        })
43
                    ->end()
44
                    ->children()
45
                        ->scalarNode('value')
46
                            ->isRequired()
47
                            ->cannotBeEmpty()
48
                        ->end()
49
                        ->scalarNode('name')
50
                            ->defaultNull()
51
                        ->end()
52
                    ->end()
53
                ->end()
54
            ->end()
55
        ->end()
56
        ;
57
        // @formatter:on
58
59
        return $treeBuilder;
60
    }
61
}
62