Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 97.65%

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 123
ccs 83
cts 85
cp 0.9765
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 117 1
1
<?php
2
3
namespace TreeHouse\IoBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
class Configuration implements ConfigurationInterface
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 2
    public function getConfigTreeBuilder()
14
    {
15 2
        $treeBuilder = new TreeBuilder();
16 2
        $rootNode = $treeBuilder->root('tree_house_io')->children();
17
18
        $rootNode
19 2
            ->scalarNode('data_dir')
20 2
            ->defaultValue('%kernel.root_dir%/var/data')
21
        ;
22
23
        $rootNode
24 2
            ->scalarNode('origin_manager_id')
25 2
            ->isRequired()
26
        ;
27
28
        $rootNode
29 2
            ->scalarNode('source_manager_id')
30 2
            ->isRequired()
31
        ;
32
33
        $rootNode
34 2
            ->scalarNode('source_processor_id')
35 2
            ->defaultValue('tree_house.io.source.processor.delegating')
36
        ;
37
38
        $rootNode
39 2
            ->scalarNode('source_cleaner_id')
40 2
            ->defaultValue('tree_house.io.source.cleaner.delegating')
41
        ;
42
43
        $rootNode
44 2
            ->arrayNode('import')
45 2
                ->addDefaultsIfNotSet()
46 2
                ->children()
47 2
                    ->scalarNode('dir')
48 2
                        ->defaultValue('%tree_house.io.data_dir%/import')
49 2
                    ->end()
50
51 2
                    ->arrayNode('item_logger')
52 2
                        ->beforeNormalization()
53 2
                            ->ifString()
54
                            ->then(function ($type) {
55
                                return ['type' => $type];
56 2
                            })
57 2
                        ->end()
58 2
                        ->children()
59 2
                            ->enumNode('type')
60 2
                                ->values(['array', 'redis', 'predis'])
61 2
                            ->end()
62 2
                            ->scalarNode('client')
63 2
                            ->end()
64 2
                            ->scalarNode('service')
65 2
                            ->end()
66 2
                        ->end()
67 2
                    ->end()
68 2
                    ->arrayNode('reader')
69 2
                        ->addDefaultsIfNotSet()
70 2
                        ->children()
71 2
                            ->arrayNode('multipart')
72 2
                                ->addDefaultsIfNotSet()
73 2
                                ->children()
74 2
                                    ->scalarNode('default_part_size')
75 2
                                        ->defaultValue(1000)
76
        ;
77
78
        $rootNode
79 2
            ->arrayNode('export')
80 2
                ->addDefaultsIfNotSet()
81 2
                ->children()
82 2
                    ->scalarNode('dir')
83 2
                        ->defaultValue('%tree_house.io.data_dir%/export')
84 2
                    ->end()
85 2
                    ->scalarNode('cache_dir')
86 2
                        ->info('Will store cache files for individual items')
87 2
                        ->defaultValue('%tree_house.io.export.dir%/cache')
88 2
                    ->end()
89 2
                    ->scalarNode('output_dir')
90 2
                        ->info('Will store final export file for all exported feeds')
91 2
                        ->defaultValue('%tree_house.io.export.dir%/generated')
92 2
                    ->end()
93 2
                ->end()
94 2
            ->end()
95
        ;
96
97
        $rootNode
98 2
            ->arrayNode('worker')
99 2
                ->addDefaultsIfNotSet()
100 2
                ->children()
101 2
                    ->arrayNode('import')
102 2
                        ->addDefaultsIfNotSet()
103 2
                        ->children()
104 2
                            ->arrayNode('import_part')
105 2
                                ->addDefaultsIfNotSet()
106 2
                                ->children()
107 2
                                    ->scalarNode('time_to_run')
108 2
                                        ->defaultValue(1200)
109 2
                                    ->end()
110 2
                                ->end()
111 2
                            ->end()
112 2
                        ->end()
113 2
                    ->end()
114 2
                ->end()
115 2
            ->end()
116
        ;
117
118
        $rootNode
119 2
            ->arrayNode('bridges')
120 2
            ->prototype('scalar')
121 2
            ->validate()
122 2
            ->ifTrue(function ($bridge) {
123
                return !in_array($bridge, ['WorkerBundle']);
124 2
            })
125 2
            ->thenInvalid('Invalid bridge %s. Valid bridge values are: "WorkerBundle"')
126
        ;
127
128 2
        return $treeBuilder;
129
    }
130
}
131