Completed
Push — master ( 6b9165...54453e )
by Peter
08:25 queued 08:22
created

Configuration   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 35
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 29 3
1
<?php
2
3
/**
4
 * GpsLab component.
5
 *
6
 * @author    Peter Gribanov <[email protected]>
7
 * @copyright Copyright (c) 2011, Peter Gribanov
8
 * @license   http://opensource.org/licenses/MIT
9
 */
10
11
namespace GpsLab\Bundle\PaginationBundle\DependencyInjection;
12
13
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
14
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15
use Symfony\Component\Config\Definition\ConfigurationInterface;
16
17
class Configuration implements ConfigurationInterface
18
{
19
    /**
20
     * @return TreeBuilder
21
     */
22 1
    public function getConfigTreeBuilder()
23
    {
24 1
        $tree_builder = new TreeBuilder('gpslab_pagination');
25
26 1
        if (method_exists($tree_builder, 'getRootNode')) {
27
            // Symfony 4.2 +
28
            $root = $tree_builder->getRootNode();
29
        } else {
30
            // Symfony 4.1 and below
31 1
            $root = $tree_builder->root('gpslab_pagination');
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\Config...der\TreeBuilder::root() has been deprecated with message: since Symfony 4.3, pass the root name to the constructor instead

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

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

Loading history...
32
        }
33
34
        // @codeCoverageIgnoreStart
35
        if (!$root instanceof ArrayNodeDefinition) {
36
            throw new \RuntimeException(sprintf(
37
                'Config root node must be a "%s", given "%s".',
38
                'Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition',
39
                get_class($root)
40
            ));
41
        }
42
        // @codeCoverageIgnoreEnd
43
44 1
        $root->addDefaultsIfNotSet();
45 1
        $root->children()->scalarNode('max_navigate')->defaultValue(5);
46 1
        $root->children()->scalarNode('parameter_name')->defaultValue('page');
47 1
        $root->children()->scalarNode('template')->defaultValue('GpsLabPaginationBundle::pagination.html.twig');
48
49 1
        return $tree_builder;
50
    }
51
}
52