Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 20
cts 20
cp 1
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace BestIt\KitchensinkBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\ConfigurationInterface;
9
10
/**
11
 * Configuration for the bundle.
12
 *
13
 * @author blange <[email protected]>
14
 * @package BestIt\KitchensinkBundle
15
 */
16
class Configuration implements ConfigurationInterface
17
{
18
    /**
19
     * Generates the configuration tree builder.
20
     * @return TreeBuilder The tree builder
21
     */
22 2
    public function getConfigTreeBuilder()
23
    {
24 2
        $builder = new TreeBuilder('best_it_kitchensink');
0 ignored issues
show
Unused Code introduced by
The call to TreeBuilder::__construct() has too many arguments starting with 'best_it_kitchensink'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
25
26 2
        $rootNode = $this->getRootNode($builder, 'best_it_kitchensink');
27
        $rootNode
28 2
            ->children()
29 2
                ->scalarNode('template')
30 2
                    ->info('Which template should be used the render the kitchensink?')
31 2
                    ->defaultValue('kitchensink/index.html.twig')
32 2
                ->end()
33 2
                ->scalarNode('data_provider')
34 2
                    ->info('The data provider service implementing the matching interface.')
35 2
                    ->isRequired()
36 2
                    ->cannotBeEmpty()
37 2
                ->end()
38 2
                ->scalarNode('template_engine')
39 2
                    ->info('The template engine service id.')
40 2
                    ->defaultValue('twig')
41 2
                    ->cannotBeEmpty()
42 2
                ->end()
43 2
            ->end();
44
45 2
        return $builder;
46
    }
47
48
    /**
49
     * BC layer for symfony/config 4.1 and older
50
     *
51
     * @param TreeBuilder $treeBuilder
52
     * @param $name
53
     *
54
     * @return ArrayNodeDefinition|NodeDefinition
55
     */
56 2
    private function getRootNode(TreeBuilder $treeBuilder, $name)
57
    {
58 2
        if (!method_exists($treeBuilder, 'getRootNode')) {
59 2
            return $treeBuilder->root($name);
60
        }
61
62
        return $treeBuilder->getRootNode();
0 ignored issues
show
Bug introduced by
The method getRootNode() does not seem to exist on object<Symfony\Component...on\Builder\TreeBuilder>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
    }
64
}
65