Test Failed
Pull Request — master (#8)
by Igor
13:17 queued 10:05
created

Configuration   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
eloc 71
c 2
b 1
f 0
dl 0
loc 94
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A addConnectionNode() 0 18 1
A addOptionsNode() 0 25 1
A getConfigTreeBuilder() 0 20 1
A addSerializationNode() 0 23 1
1
<?php
2
/*
3
 * This file is part of JSON RPC Client.
4
 *
5
 * (c) Igor Lazarev <[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
namespace Strider2038\JsonRpcClient\Bridge\Symfony\DependencyInjection;
12
13
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
14
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Config\Definition\ConfigurationInterface;
17
18
/**
19
 * @author Igor Lazarev <[email protected]>
20
 */
21
class Configuration implements ConfigurationInterface
22
{
23
    public function getConfigTreeBuilder(): TreeBuilder
24
    {
25
        $treeBuilder = new TreeBuilder('json_rpc_client');
26
        $rootNode = $treeBuilder->getRootNode();
27
28
        $rootNode
29
            ->performNoDeepMerging()
0 ignored issues
show
Bug introduced by
The method performNoDeepMerging() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
            ->/** @scrutinizer ignore-call */ 
30
              performNoDeepMerging()
Loading history...
30
            ->requiresAtLeastOneElement()
31
            ->arrayPrototype()
32
                ->children()
33
                    ->scalarNode('url')
34
                        ->info('Connection string to JSON RPC server, for example "http://localhost:1234"')
35
                        ->isRequired()
36
                        ->cannotBeEmpty()
37
                    ->end()
38
                    ->append($this->addOptionsNode())
39
                ->end()
40
            ->end();
41
42
        return $treeBuilder;
43
    }
44
45
    private function addOptionsNode(): NodeDefinition
46
    {
47
        $node = new ArrayNodeDefinition('options');
48
49
        $node
50
            ->children()
51
                ->integerNode('request_timeout_us')
52
                    ->info('Request timeout in microseconds')
53
                ->end()
54
                ->booleanNode('enable_response_processing')
0 ignored issues
show
Bug introduced by
The method booleanNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
                ->/** @scrutinizer ignore-call */ booleanNode('enable_response_processing')
Loading history...
55
                    ->info('If enabled then successful responses will be unpacked and exceptions will be thrown on errors')
56
                    ->defaultTrue()
57
                ->end()
58
                ->append($this->addConnectionNode())
59
                ->enumNode('http_client_type')
60
                    ->info('Preferred HTTP client')
61
                    ->defaultValue('symfony')
62
                    ->values(['symfony', 'guzzle'])
63
                ->end()
64
                ->variableNode('transport_configuration')
65
                ->end()
66
                ->append($this->addSerializationNode())
67
            ->end();
68
69
        return $node;
70
    }
71
72
    private function addConnectionNode(): NodeDefinition
73
    {
74
        $node = new ArrayNodeDefinition('connection');
75
76
        $node
77
            ->children()
78
                ->integerNode('attempt_timeout_us')
79
                    ->info('Reconnection attempt timeout in microseconds. Must be greater than zero.')
80
                ->end()
81
                ->floatNode('timeout_multiplier')
0 ignored issues
show
Bug introduced by
The method floatNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
                ->/** @scrutinizer ignore-call */ floatNode('timeout_multiplier')
Loading history...
82
                    ->info('Used to increase timeout value with growing reconnection attempts. Must be greater than 1.0.')
83
                ->end()
84
                ->integerNode('max_attempts')
85
                    ->info('Max sequential attempts to reconnect with remote server. Must be greater or equal to 1.')
86
                ->end()
87
            ->end();
88
89
        return $node;
90
    }
91
92
    private function addSerializationNode(): NodeDefinition
93
    {
94
        $node = new ArrayNodeDefinition('serialization');
95
96
        $node
97
            ->children()
98
                ->enumNode('serializer_type')
99
                    ->defaultValue('symfony')
100
                    ->values(['symfony', 'object', 'array'])
101
                ->end()
102
                ->arrayNode('result_types_by_methods')
0 ignored issues
show
Bug introduced by
The method arrayNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

102
                ->/** @scrutinizer ignore-call */ arrayNode('result_types_by_methods')
Loading history...
103
                    ->defaultValue([])
104
                    ->scalarPrototype()->end()
105
                ->end()
106
                ->scalarNode('default_error_type')
107
                ->end()
108
                ->arrayNode('error_types_by_methods')
109
                    ->defaultValue([])
110
                    ->scalarPrototype()->end()
111
                ->end()
112
            ->end();
113
114
        return $node;
115
    }
116
}
117