Completed
Push — master ( 770316...74fc07 )
by Jeroen
09:08 queued 02:44
created

Configuration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 97.96%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 72
ccs 48
cts 49
cp 0.9796
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 66 2
1
<?php
2
3
namespace Kunstmaan\TranslatorBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * This is the class that validates and merges configuration from your app/config files
10
 *
11
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
12
 */
13
class Configuration implements ConfigurationInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 5
    public function getConfigTreeBuilder()
19
    {
20 5
        $treeBuilder = new TreeBuilder('kuma_translator');
21 5
        if (method_exists($treeBuilder, 'getRootNode')) {
22 5
            $rootNode = $treeBuilder->getRootNode();
23
        } else {
24
            // BC layer for symfony/config 4.1 and older
25
            $rootNode = $treeBuilder->root('kuma_translator');
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\Config...der\TreeBuilder::root() has been deprecated with message: since Symfony 4.3, pass the root name to the constructor instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
26
        }
27
28 5
        $availableStorageEngines = ['orm'];
29 5
        $defaultFileFormats = ['yml', 'yaml', 'xliff'];
30
31
        $rootNode
32 5
            ->children()
33 5
                ->booleanNode('enabled')
34 5
                    ->defaultTrue()
35 5
                ->end()
36
37 5
                ->scalarNode('default_bundle')
38 5
                    ->cannotBeEmpty()
39 5
                    ->defaultValue('own')
40 5
                ->end()
41
42 5
                ->arrayNode('bundles')
43 5
                    ->defaultValue(array())
44 5
                    ->prototype('scalar')->end()
45 5
                ->end()
46
47 5
                ->scalarNode('cache_dir')
48 5
                    ->cannotBeEmpty()
49 5
                    ->defaultValue('%kernel.cache_dir%/translations')
50 5
                ->end()
51
52 5
                ->booleanNode('debug')
53 5
                    ->defaultValue(null)
54 5
                ->end()
55
56 5
                ->arrayNode('managed_locales')
57 5
                    ->defaultValue(array())
58 5
                    ->prototype('scalar')->end()
59 5
                ->end()
60
61 5
                ->arrayNode('file_formats')
62 5
                    ->defaultValue($defaultFileFormats)
63 5
                    ->prototype('scalar')->end()
64 5
                ->end()
65
66 5
                ->arrayNode('storage_engine')
67 5
                    ->addDefaultsIfNotSet()
68 5
                    ->children()
69 5
                        ->scalarNode('type')
70 5
                            ->cannotBeEmpty()
71 5
                            ->defaultValue('orm')
72 5
                            ->validate()
73 5
                                ->ifNotInArray($availableStorageEngines)
74 5
                                ->thenInvalid('Storage engine should be one of the following: '.implode(', ', $availableStorageEngines))
75 5
                            ->end()
76 5
                        ->end()
77 5
                    ->end()
78 5
                ->end()
79 5
            ->end()
80
        ;
81
82 5
        return $treeBuilder;
83
    }
84
}
85