Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 39
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 45 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\DAOBundle\DependencyInjection;
6
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\ConfigurationInterface;
9
10
final class Configuration implements ConfigurationInterface
11
{
12
    public function getConfigTreeBuilder(): TreeBuilder
13
    {
14
        if (method_exists(TreeBuilder::class, 'getRootNode')) {
15
            $treeBuilder = new TreeBuilder('setono_dao');
16
            $rootNode = $treeBuilder->getRootNode();
17
        } else {
18
            // BC layer for symfony/config 4.1 and older
19
            $treeBuilder = new TreeBuilder();
20
            $rootNode = $treeBuilder->root('setono_dao');
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Component\Config...der\TreeBuilder::root() has been deprecated: since Symfony 4.3, pass the root name to the constructor instead ( Ignorable by Annotation )

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

20
            $rootNode = /** @scrutinizer ignore-deprecated */ $treeBuilder->root('setono_dao');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
21
        }
22
23
        $rootNode
24
            ->addDefaultsIfNotSet()
0 ignored issues
show
Bug introduced by
The method addDefaultsIfNotSet() 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

24
            ->/** @scrutinizer ignore-call */ 
25
              addDefaultsIfNotSet()
Loading history...
25
            ->children()
26
                ->scalarNode('customer_id')
27
                    ->isRequired()
28
                    ->cannotBeEmpty()
29
                    ->info('Your DAO customer id')
30
                ->end()
31
                ->scalarNode('password')
32
                    ->isRequired()
33
                    ->cannotBeEmpty()
34
                    ->info('Your DAO password')
35
                ->end()
36
                ->scalarNode('base_url')
37
                    ->cannotBeEmpty()
38
                    ->defaultValue('https://api.dao.as')
39
                    ->info('The base URL of the DAO API')
40
                ->end()
41
                ->scalarNode('http_client')
42
                    ->cannotBeEmpty()
43
                    ->info('PSR18 HTTP client that is injected into the client service')
44
                ->end()
45
                ->scalarNode('request_factory')
46
                    ->cannotBeEmpty()
47
                    ->info('Is injected into the client service')
48
                ->end()
49
                ->scalarNode('stream_factory')
50
                    ->cannotBeEmpty()
51
                    ->info('Is injected into the client service')
52
                ->end()
53
            ->end()
54
        ;
55
56
        return $treeBuilder;
57
    }
58
}
59