Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 29 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusPaginationPlugin\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
    /**
13
     * {@inheritdoc}
14
     */
15
    public function getConfigTreeBuilder(): TreeBuilder
16
    {
17
        if (method_exists(TreeBuilder::class, 'getRootNode')) {
18
            $treeBuilder = new TreeBuilder('setono_sylius_pagination');
19
            $rootNode = $treeBuilder->getRootNode();
20
        } else {
21
            // BC layer for symfony/config 4.1 and older
22
            $treeBuilder = new TreeBuilder();
23
            $rootNode = $treeBuilder->root('setono_sylius_pagination');
24
        }
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
            ->fixXmlConfig('event')
29
            ->children()
30
                ->scalarNode('page_parameter')
31
                    ->defaultValue('page')
32
                    ->cannotBeEmpty()
33
                    ->info('The query parameter indicating af pagination')
34
                    ->example('page')
35
                ->end()
36
                ->booleanNode('listen_to_resources')->defaultTrue()->end()
37
                ->arrayNode('events')
38
                    ->scalarPrototype()->end()
39
                ->end()
40
            ->end()
41
        ;
42
43
        return $treeBuilder;
44
    }
45
}
46