Completed
Push — upgrade ( f08820...3a8411 )
by Simonas
02:02
created

Configuration::getManagersNode()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 97

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 97
rs 8.0654
c 0
b 0
f 0
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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 ONGR\ElasticsearchBundle\DependencyInjection;
13
14
use Psr\Log\LogLevel;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Config\Definition\ConfigurationInterface;
17
18
/**
19
 * This is the class that validates and merges configuration from app/config files.
20
 */
21
class Configuration implements ConfigurationInterface
22
{
23
    CONST ONGR_CACHE_CONFIG = 'ongr.esb.cache';
24
    CONST ONGR_PROFILER_CONFIG = 'ongr.esb.profiler';
25
    CONST ONGR_ANALYSIS_CONFIG = 'ongr.esb.analysis';
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function getConfigTreeBuilder()
31
    {
32
        $treeBuilder = new TreeBuilder();
33
        $rootNode = $treeBuilder->root('ongr_elasticsearch');
34
35
        $rootNode
36
            ->children()
37
38
            ->booleanNode('cache')
39
                ->info(
40
                    'Enables the cache handler to store important data to the cache. '.
41
                    'Default value is kernel.debug parameter.'
42
                )
43
            ->end()
44
45
            ->booleanNode('profiler')
46
                ->info(
47
                    'Enables Symfony profiler for the elasticsearch queries debug.'.
48
                    'Default value is kernel.debug parameter. '
49
                )
50
            ->end()
51
52
            ->arrayNode('include_dir')
53
                ->info('Here you can include additional directories if you have index documents somewhere out of your project `src/` directory.')
54
                ->defaultValue([])
55
                ->prototype('scalar')->end()
56
            ->end()
57
58
            ->append($this->getAnalysisNode())
59
60
            ->end();
61
62
        return $treeBuilder;
63
    }
64
65
    /**
66
     * Analysis configuration node.
67
     *
68
     * @return \Symfony\Component\Config\Definition\Builder\NodeDefinition
69
     */
70
    private function getAnalysisNode()
71
    {
72
        $builder = new TreeBuilder();
73
        $node = $builder->root('analysis');
74
75
        $node
76
            ->info('Defines analyzers, normalizers, tokenizers and filters')
77
            ->addDefaultsIfNotSet()
78
            ->children()
79
                ->arrayNode('tokenizer')
80
                    ->defaultValue([])
81
                    ->prototype('variable')->end()
82
                ->end()
83
                ->arrayNode('filter')
84
                    ->defaultValue([])
85
                    ->prototype('variable')->end()
86
                ->end()
87
                ->arrayNode('analyzer')
88
                    ->defaultValue([])
89
                    ->prototype('variable')->end()
90
                ->end()
91
                ->arrayNode('normalizer')
92
                    ->defaultValue([])
93
                    ->prototype('variable')->end()
94
                ->end()
95
                ->arrayNode('char_filter')
96
                    ->defaultValue([])
97
                    ->prototype('variable')->end()
98
                ->end()
99
            ->end();
100
101
        return $node;
102
    }
103
}
104