Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 47
ccs 28
cts 28
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 38 1
1
<?php
2
3
/*
4
 * This file is part of the Ivoaz ContentEditable bundle.
5
 *
6
 * (c) Ivo Azirjans <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Ivoaz\Bundle\ContentEditableBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15
use Symfony\Component\Config\Definition\ConfigurationInterface;
16
17
/**
18
 * @author Ivo Azirjans <[email protected]>
19
 */
20
class Configuration implements ConfigurationInterface
21
{
22
    const MODEL_ORM = 'orm';
23
    const MODEL_MONGODB = 'mongodb';
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 9
    public function getConfigTreeBuilder()
29
    {
30 9
        $treeBuilder = new TreeBuilder();
31 9
        $rootNode = $treeBuilder->root('ivoaz_content_editable');
32
33 9
        $supportedModelTypes = [self::MODEL_ORM, self::MODEL_MONGODB];
34
35
        $rootNode
36 9
            ->addDefaultsIfNotSet()
37 9
            ->children()
38
39 9
                ->scalarNode('model_type')
40 9
                    ->validate()
41 9
                        ->ifNotInArray($supportedModelTypes)
42 9
                        ->thenInvalid(
43 9
                            sprintf(
44 9
                                'The model type "%%s" is not supported. Please use one of the following model type: %s.',
45 9
                                implode(', ', $supportedModelTypes)
46 9
                            )
47 9
                        )
48 9
                    ->end()
49 9
                    ->cannotBeEmpty()
50 9
                    ->defaultValue(self::MODEL_ORM)
51 9
                ->end()
52
53 9
                ->scalarNode('model_manager_name')
54 9
                    ->defaultValue(null)
55 9
                ->end()
56
57 9
                ->scalarNode('editor')
58 9
                    ->cannotBeEmpty()
59 9
                    ->defaultValue('ivoaz_content_editable.default_editor')
60 9
                ->end()
61
62 9
            ->end();
63
64 9
        return $treeBuilder;
65
    }
66
}
67