Configuration   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 82.14%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 46
ccs 23
cts 28
cp 0.8214
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 17 2
A storagesConfig() 0 22 2
1
<?php
2
3
/*
4
 * This file is part of Sulu.
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
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 Sulu\Bundle\ActivityLogBundle\DependencyInjection;
13
14
use Sulu\Bundle\ElasticsearchActivityLogBundle\Storage\ElasticsearchActivityStorage;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Config\Definition\ConfigurationInterface;
17
18
/**
19
 * Initializes configuration tree for activity-log-bundle.
20
 */
21
class Configuration implements ConfigurationInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function getConfigTreeBuilder()
27
    {
28 1
        $storages = ['array', 'custom'];
29
30 1
        if (class_exists(ElasticsearchActivityStorage::class)) {
31
            $storages[] = 'elastic';
32
        }
33
34 1
        $treeBuilder = new TreeBuilder();
35 1
        $treeBuilder->root('sulu_activity_log')
36 1
            ->children()
37 1
                ->enumNode('storage')
38 1
                    ->values($storages)->end()
39 1
                ->append($this->storagesConfig());
40
41 1
        return $treeBuilder;
42
    }
43
44 1
    private function storagesConfig()
45
    {
46 1
        $treeBuilder = new TreeBuilder();
47 1
        $children = $treeBuilder->root('storages')
48 1
            ->children()
49 1
                ->arrayNode('array')
50 1
                ->end()
51 1
                ->arrayNode('custom')
52 1
                    ->children()
53 1
                        ->scalarNode('id')->end()
54 1
                    ->end()
55 1
                ->end();
56
57 1
        if (class_exists(ElasticsearchActivityStorage::class)) {
58
            $children->arrayNode('elastic')
59
                ->children()
60
                    ->scalarNode('ongr_manager')->end()
61
                ->end();
62
        }
63
64 1
        return $children->end();
65
    }
66
}
67