Passed
Branch master (4407aa)
by ANTHONIUS
02:45
created

Configuration::addServiceSection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 1
dl 0
loc 16
ccs 14
cts 14
cp 1
crap 1
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the DoyoUserBundle project.
5
 *
6
 * (c) Anthonius Munthi <[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
declare(strict_types=1);
13
14
namespace Doyo\UserBundle\DependencyInjection;
15
16
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
17
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
18
use Symfony\Component\Config\Definition\ConfigurationInterface;
19
20
class Configuration implements ConfigurationInterface
21
{
22 1
    public function getConfigTreeBuilder()
23
    {
24 1
        $treeBuilder = new TreeBuilder('doyo_user');
25
26
        //@codeCoverageIgnoreStart
27
        if (method_exists($treeBuilder, 'getRootNode')) {
28
            $rootNode = $treeBuilder->getRootNode();
29
        } else {
30
            $rootNode = $treeBuilder->root('doyo_user');
31
        }
32
        //@codeCoverageIgnoreEnd
33
34
        $rootNode
35 1
            ->children()
36 1
                ->scalarNode('db_driver')->defaultValue('orm')->end()
37 1
                ->scalarNode('user_class')->isRequired()->cannotBeEmpty()->end()
38 1
                ->scalarNode('model_manager_name')->defaultValue('default')->end()
39 1
                ->booleanNode('api_platform')->defaultValue(false)->end()
40 1
            ->end();
41 1
        $this->addServiceSection($rootNode);
42
43 1
        return $treeBuilder;
44
    }
45
46 1
    private function addServiceSection(ArrayNodeDefinition $node)
47
    {
48
        $node
49 1
            ->addDefaultsIfNotSet()
50 1
            ->children()
51 1
                ->arrayNode('service')
52 1
                    ->addDefaultsIfNotSet()
53 1
                        ->children()
54 1
                            ->scalarNode('email_canonicalizer')->defaultValue('doyo_user.util.canonicalizer.default')->end()
55 1
                            ->scalarNode('username_canonicalizer')->defaultValue('doyo_user.util.canonicalizer.default')->end()
0 ignored issues
show
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

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

55
                            ->/** @scrutinizer ignore-call */ scalarNode('username_canonicalizer')->defaultValue('doyo_user.util.canonicalizer.default')->end()
Loading history...
56 1
                            ->scalarNode('password_updater')->defaultValue('doyo_user.util.password_updater.default')->end()
57 1
                            ->scalarNode('user_manager')->defaultValue('doyo_user.user_manager.default')->end()
58 1
                        ->end()
59 1
                    ->end()
60 1
                ->end()
61 1
            ->end();
62
    }
63
}
64