Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 21 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusReserveStockPlugin\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
    private const DEFAULT_TTL = 3600;
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function getConfigTreeBuilder(): TreeBuilder
18
    {
19
        if (method_exists(TreeBuilder::class, 'getRootNode')) {
20
            $treeBuilder = new TreeBuilder('setono_sylius_reserve_stock');
21
            $rootNode = $treeBuilder->getRootNode();
22
        } else {
23
            $treeBuilder = new TreeBuilder();
24
            $rootNode = $treeBuilder->root('setono_sylius_reserve_stock');
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

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

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...
25
        }
26
        $rootNode
27
            ->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

27
            ->/** @scrutinizer ignore-call */ 
28
              addDefaultsIfNotSet()
Loading history...
28
            ->children()
29
                ->integerNode('ttl')
30
                    ->defaultValue(self::DEFAULT_TTL)
31
                    ->example(1800)
32
                    ->info('Define the Time To Live (TTL) in seconds for a product reservation. Setting to 0 disables this check, all carts will be taken in account for an indefinite period.')
33
                ->end()
34
            ->end()
35
        ;
36
37
        return $treeBuilder;
38
    }
39
}
40