Configuration   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 18
dl 0
loc 31
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 16 2
A addTableSection() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\Doctrine\Bridge\Symfony\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Config\Definition\ConfigurationInterface;
17
18
final class Configuration implements ConfigurationInterface
19
{
20
    public function getConfigTreeBuilder()
21
    {
22
        $treeBuilder = new TreeBuilder('core23_doctrine');
23
24
        // Keep compatibility with symfony/config < 4.2
25
        if (!method_exists(TreeBuilder::class, 'getRootNode')) {
26
            $rootNode = $treeBuilder->root('core23_doctrine');
0 ignored issues
show
Bug introduced by core23
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

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

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...
27
        } else {
28
            $rootNode = $treeBuilder->getRootNode();
29
        }
30
31
        \assert($rootNode instanceof ArrayNodeDefinition);
32
33
        $this->addTableSection($rootNode);
34
35
        return $treeBuilder;
36
    }
37
38
    private function addTableSection(ArrayNodeDefinition $node): void
39
    {
40
        $node
41
            ->children()
42
                ->arrayNode('table')
43
                    ->addDefaultsIfNotSet()
44
                    ->children()
45
                        ->scalarNode('prefix')->defaultNull()->end()
46
                    ->end()
0 ignored issues
show
Bug introduced by core23
The method end() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder. Are you sure you never get one of those? ( Ignorable by Annotation )

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

46
                    ->/** @scrutinizer ignore-call */ end()
Loading history...
47
                ->end()
48
            ->end()
49
        ;
50
    }
51
}
52