Test Setup Failed
Branch 0.x (5da7af)
by Pavel
13:48
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 59
rs 8.8945
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 Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[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
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AnthillBundle\DependencyInjection;
17
18
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
19
use Symfony\Component\Config\Definition\ConfigurationInterface;
20
21
/**
22
 * AnthillBundle configuration.
23
 */
24
class Configuration implements ConfigurationInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getConfigTreeBuilder()
30
    {
31
        $treeBuilder = new TreeBuilder();
32
        $rootNode    = $treeBuilder->root('veslo_anthill');
33
34
        $rootNode
35
            ->children()
36
                ->arrayNode('vacancy')
37
                    ->children()
38
                        ->arrayNode('digging')
39
                            ->children()
40
                                ->arrayNode('roadmap')
41
                                    ->children()
42
                                        ->integerNode('attempts_until_pause')
43
                                            ->info('How much vacancy search attempts cranky dung beetle should perform via roadmap before give up')
44
                                            ->isRequired()
45
                                            ->min(1)
46
                                        ->end()
47
                                        ->integerNode('pause_duration')
48
                                            ->info('Give up time in seconds for cranky dung beetle after too much unsuccessful vacancy search attempts')
49
                                            ->isRequired()
50
                                            ->min(10)
51
                                        ->end()
52
                                    ->end()
53
                                ->end()
54
                            ->end()
55
                        ->end()
56
                        ->arrayNode('provider')
57
                            ->info('Options for vacancy providers')
58
                            ->children()
59
                                ->integerNode('per_page')
60
                                    ->info('Vacancies count per page for rendering during list action')
61
                                    ->isRequired()
62
                                    ->min(1)
63
                                ->end()
64
                            ->end()
65
                        ->end()
66
                        ->arrayNode('repository')
67
                            ->info('Options for vacancy repository')
68
                            ->children()
69
                                ->scalarNode('cache_result_namespace')
70
                                    ->info('Query result cache namespace for vacancy repository')
71
                                    ->isRequired()
72
                                    ->cannotBeEmpty()
73
                                ->end()
74
                                ->integerNode('cache_result_lifetime')
75
                                    ->info('How long query result cache will be available after successful put; during this time some data changes on website will not be seen, for example, vacancy list')
76
                                    ->isRequired()
77
                                    ->min(0)
78
                                ->end()
79
                            ->end()
80
                        ->end()
81
                    ->end()
82
                ->end()
83
            ->end()
84
        ;
85
86
        return $treeBuilder;
87
    }
88
}
89