Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 2 Features 0
Metric Value
eloc 14
c 3
b 2
f 0
dl 0
loc 21
rs 9.7998
cc 2
nc 2
nop 0
1
<?php
2
namespace Alister\ReservedNamesBundle\DependencyInjection;
3
4
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
5
use Symfony\Component\Config\Definition\ConfigurationInterface;
6
7
/**
8
 * This is the class that validates and merges configuration from your app/config files.
9
 *
10
 * To learn more see
11
 * {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
12
 */
13
class Configuration implements ConfigurationInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function getConfigTreeBuilder()
19
    {
20
        $treeBuilder = new TreeBuilder('alister_reserved_names');
21
        if (method_exists($treeBuilder, 'getRootNode')) {
22
            $rootNode = $treeBuilder->getRootNode();
23
        } else {
24
            // BC layer for symfony/config 4.1 and older
25
            $rootNode = $treeBuilder->root('alister_reserved_names');
0 ignored issues
show
Bug introduced by
The method root() does not exist on Symfony\Component\Config...ion\Builder\TreeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            /** @scrutinizer ignore-call */ 
26
            $rootNode = $treeBuilder->root('alister_reserved_names');

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...
26
        }
27
28
        $rootNode
29
            ->children()
30
                //->scalarNode('clean_username')->defaultValue('xiidea.clean_username.class')->end()
31
                ->variableNode('names')
32
                    ->defaultValue(['reservedname', 'woz'])
33
                    ->info('multiple names that will not be allowed as new users')
34
                    ->example('billgates, stevewoz')
35
                ->end()
36
            ->end();
37
38
        return $treeBuilder;
39
    }
40
}
41