Completed
Push — master ( cc9f19...85e40f )
by Pavel
11s
created

DbConfigDefinition   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 88
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 82 1
1
<?php
2
3
namespace App\Common\Config\Definition;
4
5
use Symfony\Component\Config\Definition\ConfigurationInterface;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
8
/**
9
 * @inheritdoc
10
 */
11
class DbConfigDefinition implements ConfigurationInterface
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public function getConfigTreeBuilder()
17
    {
18
        $treeBuilder = new TreeBuilder();
19
        $rootNode = $treeBuilder->root(null);
20
21
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
44% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
22
         * verify the following structure
23
         * return [
24
         *       'definition' => DBConfigDefinition::class,
25
         *
26
         *       'database' => [
27
         *           'connections' => [
28
         *               'default' => [
29
         *                   'driver'    => 'mysql',
30
         *                   'host'      => 'localhost',
31
         *                   'database'  => 'bootstrapi',
32
         *                   'username'  => 'root',
33
         *                   'password'  => 'qwerty',
34
         *                   'charset'   => 'utf8',
35
         *                   'collation' => 'utf8_unicode_ci',
36
         *                   'prefix'    => '',
37
         *               ],
38
         *           ],
39
         *       ],
40
         *   ];
41
         */
42
        $rootNode
43
            ->children()
44
                // 'definition' => DBConfigDefinition::class,
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
                ->scalarNode('definition')
46
                    ->isRequired()
47
                    ->cannotBeEmpty()
48
                ->end()
49
50
                // 'database' => []
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51
                ->arrayNode('database')
52
                    ->children()
53
                        // 'connections' => []
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
54
                        ->arrayNode('connections')
55
56
                            // multiple connection specifications can be inside 'connections' section
57
                            // each of connections specifications has its own name
58
                            ->useAttributeAsKey('name')
59
                            ->prototype('array')
60
61
                                ->children()
62
                                    // connection params
63
64
                                    ->scalarNode('driver')
65
                                        ->defaultValue('mysql')
66
                                    ->end()
67
                                    ->scalarNode('host')
68
                                        ->defaultValue('localhost')
69
                                    ->end()
70
                                    ->scalarNode('database')
71
                                        ->isRequired()
72
                                        ->cannotBeEmpty()
73
                                    ->end()
74
                                    ->scalarNode('username')
75
                                        ->defaultValue('root')
76
                                    ->end()
77
                                    ->scalarNode('password')
78
                                        ->defaultValue(null)
79
                                    ->end()
80
                                    ->scalarNode('charset')->end()
81
                                    ->scalarNode('collation')->end()
82
                                    ->scalarNode('prefix')->end()
83
84
                                    ->scalarNode('self-filled')
85
                                        ->defaultValue('some value')
86
                                    ->end()
87
88
                                ->end()
89
                            ->end()
90
                        ->end()
91
                    ->end()
92
                ->end()
93
            ->end()
94
        ;
95
96
        return $treeBuilder;
97
    }
98
}
99