Configuration::getConfigTreeBuilder()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 80
Code Lines 75

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 75
c 1
b 0
f 0
dl 0
loc 80
rs 8.5454
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
                                ->arrayNode('journal')
60
                                    ->children()
61
                                        ->integerNode('per_page')
62
                                            ->info('Vacancies count per page for rendering during list action')
63
                                            ->isRequired()
64
                                            ->min(1)
65
                                        ->end()
66
                                        ->integerNode('max_days_after_publication')
67
                                            ->info('How many days after publication are allowed for a vacancy to be rendered in "fresh" lists')
68
                                            ->isRequired()
69
                                            ->min(1)
70
                                        ->end()
71
                                    ->end()
72
                                ->end()
73
                                ->arrayNode('archive')
74
                                    ->children()
75
                                        ->integerNode('per_page')
76
                                            ->isRequired()
77
                                            ->min(1)
78
                                        ->end()
79
                                        ->integerNode('min_days_after_publication')
80
                                            ->info('Minimum days after publication that is required for a vacancy to be considered as "archived"')
81
                                            ->isRequired()
82
                                            ->min(1)
83
                                        ->end()
84
                                    ->end()
85
                                ->end()
86
                            ->end()
87
                        ->end()
88
                        ->arrayNode('repository')
89
                            ->info('Options for vacancy repository')
90
                            ->children()
91
                                ->scalarNode('cache_result_namespace')
92
                                    ->info('Query result cache namespace for vacancy repository')
93
                                    ->isRequired()
94
                                    ->cannotBeEmpty()
95
                                ->end()
96
                                ->integerNode('cache_result_lifetime')
97
                                    ->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')
98
                                    ->isRequired()
99
                                    ->min(0)
100
                                ->end()
101
                            ->end()
102
                        ->end()
103
                    ->end()
104
                ->end()
105
            ->end()
106
        ;
107
108
        return $treeBuilder;
109
    }
110
}
111