BundleConfigurationBuilder::addBaseEntityManager()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

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