Completed
Push — master ( 8c5b1a...9a26dd )
by Tomáš
17:38
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 1
c 2
b 0
f 2
lcom 1
cbo 3
dl 0
loc 38
ccs 15
cts 15
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 20 1
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2015 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\DefaultAutowire\Config\Definition;
9
10
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
11
use Symfony\Component\Config\Definition\ConfigurationInterface;
12
use Symplify\DefaultAutowire\SymplifyDefaultAutowireBundle;
13
14
final class Configuration implements ConfigurationInterface
15
{
16
    /**
17
     * @var string[]
18
     */
19
    private $defaultAutowireTypes = [
20
        'Doctrine\ORM\EntityManager' => 'doctrine.orm.default_entity_manager',
21
        'Doctrine\ORM\EntityManagerInterface' => 'doctrine.orm.default_entity_manager',
22
        'Doctrine\Portability\Connection' => 'database_connection',
23
        'Symfony\Component\EventDispatcher\EventDispatcher' => 'event_dispatcher',
24
        'Symfony\Component\EventDispatcher\EventDispatcherInterface' => 'event_dispatcher',
25
        'Symfony\Component\Translation\TranslatorInterface' => 'translator',
26
    ];
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 5
    public function getConfigTreeBuilder()
32
    {
33 5
        $treeBuilder = new TreeBuilder();
34
35 5
        $rootNode = $treeBuilder->root(SymplifyDefaultAutowireBundle::ALIAS);
36
37 5
        $rootNode->children()
38 5
            ->arrayNode('autowire_types')
39 5
                ->beforeNormalization()
40 5
                    ->ifArray()
41 5
                    ->then(function ($value) {
42 2
                        return array_merge($this->defaultAutowireTypes, $value);
43 5
                    })
44 5
                ->end()
45 5
                ->defaultValue($this->defaultAutowireTypes)
46 5
                ->prototype('scalar')
47 5
            ->end();
48
49 5
        return $treeBuilder;
50
    }
51
}
52