Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3.009

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 9
cts 10
cp 0.9
rs 9.52
c 0
b 0
f 0
cc 3
nc 4
nop 0
crap 3.009
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 1
            $root = $tree_builder->getRootNode();
29
        } else {
30
            // Symfony 4.1 and below
31
            $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('Config root node must be a "%s", given "%s".', 'Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition', get_class($root)));
37
        }
38
        // @codeCoverageIgnoreEnd
39
40 1
        $root->addDefaultsIfNotSet();
41 1
        $root->children()->scalarNode('max_navigate')->defaultValue(5);
42 1
        $root->children()->scalarNode('parameter_name')->defaultValue('page');
43 1
        $root->children()->scalarNode('template')->defaultValue('GpsLabPaginationBundle::pagination.html.twig');
44
45 1
        return $tree_builder;
46
    }
47
}
48