Completed
Pull Request — master (#601)
by Mike
02:22
created

BundleConfigurationBuilder::addBaseConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Bundle\DoctrineBundle\Tests\Builder;
4
5
6
class BundleConfigurationBuilder
7
{
8
9
    private $configuration;
10
11
    public static function createBuilder()
12
    {
13
        return new self();
14
    }
15
16
    public static function createBuilderWithBaseValues()
17
    {
18
        $builder = new self();
19
        $builder->addBaseConnection();
20
        $builder->addBaseEntityManager();
21
22
        return $builder;
23
    }
24
25
    public function addBaseConnection()
26
    {
27
        $this->addConnection([
28
            'connections' => [
29
                'default' => [
30
                    'password' => 'foo'
31
                ]
32
            ]
33
        ]);
34
35
        return $this;
36
    }
37
38
    public function addBaseEntityManager()
39
    {
40
        $this->addEntityManager([
41
            'default_entity_manager' => 'default',
42
            'entity_managers' => [
43
                'default' => [
44
                    'mappings' => [
45
                        'YamlBundle' => []
46
                    ]
47
                ]
48
            ]
49
        ]);
50
51
        return $this;
52
    }
53
54
    public function addBaseSecondLevelCache()
55
    {
56
        $this->addSecondLevelCache([
57
            'region_cache_driver' => [
58
                'type' => 'memcache'
59
            ],
60
            'regions' => [
61
                'hour_region' => [
62
                    'lifetime' => 3600
63
                ]
64
            ]
65
        ]);
66
67
        return $this;
68
    }
69
70
    public function addConnection($config)
71
    {
72
        $this->configuration['dbal'] = $config;
73
74
        return $this;
75
    }
76
77
    public function addEntityManager($config)
78
    {
79
        $this->configuration['orm'] = $config;
80
81
        return $this;
82
    }
83
84
    public function addSecondLevelCache($config, $manager = 'default')
85
    {
86
        $this->configuration['orm']['entity_managers'][$manager]['second_level_cache'] = $config;
87
88
        return $this;
89
    }
90
91
    public function build()
92
    {
93
        return $this->configuration;
94
    }
95
}
96