Passed
Pull Request — 4.2 (#140)
by David
09:31
created

AlteredConfiguration::getNamingStrategy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
4
namespace Mouf\Database\TDBM\Commands;
5
6
use Doctrine\Common\Cache\Cache;
7
use Doctrine\DBAL\Connection;
8
use Mouf\Database\SchemaAnalyzer\SchemaAnalyzer;
9
use Mouf\Database\TDBM\ConfigurationInterface;
10
use Mouf\Database\TDBM\Utils\GeneratorListenerInterface;
11
use Mouf\Database\TDBM\Utils\NamingStrategyInterface;
12
use Psr\Log\LoggerInterface;
13
14
/**
15
 * A class to alter any ConfigurationInterface on the fly.
16
 *
17
 * The logger can be altered with setLogger method.
18
 * Useful to dynamically register a logger in the Symfony commands.
19
 */
20
class AlteredConfiguration implements ConfigurationInterface
21
{
22
    /**
23
     * @var ConfigurationInterface
24
     */
25
    private $configuration;
26
27
    /**
28
     * @var LoggerInterface
29
     */
30
    private $logger;
31
32
    public function __construct(ConfigurationInterface $configuration)
33
    {
34
        $this->configuration = $configuration;
35
        $this->logger = $configuration->getLogger();
36
    }
37
38
39
    /**
40
     * @return string
41
     */
42
    public function getBeanNamespace(): string
43
    {
44
        return $this->configuration->getBeanNamespace();
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function getDaoNamespace(): string
51
    {
52
        return $this->configuration->getDaoNamespace();
53
    }
54
55
    /**
56
     * @return Connection
57
     */
58
    public function getConnection(): Connection
59
    {
60
        return $this->configuration->getConnection();
61
    }
62
63
    /**
64
     * @return Cache
65
     */
66
    public function getCache(): Cache
67
    {
68
        return $this->configuration->getCache();
69
    }
70
71
    /**
72
     * @return NamingStrategyInterface
73
     */
74
    public function getNamingStrategy(): NamingStrategyInterface
75
    {
76
        return $this->configuration->getNamingStrategy();
77
    }
78
79
    /**
80
     * @return SchemaAnalyzer
81
     */
82
    public function getSchemaAnalyzer(): SchemaAnalyzer
83
    {
84
        return $this->configuration->getSchemaAnalyzer();
85
    }
86
87
    /**
88
     * @return LoggerInterface
89
     */
90
    public function getLogger(): ?LoggerInterface
91
    {
92
        return $this->configuration->getLogger();
93
    }
94
95
    /**
96
     * @return GeneratorListenerInterface
97
     */
98
    public function getGeneratorEventDispatcher(): GeneratorListenerInterface
99
    {
100
        return $this->configuration->getGeneratorEventDispatcher();
101
    }
102
103
    /**
104
     * @param LoggerInterface $logger
105
     */
106
    public function setLogger(LoggerInterface $logger)
107
    {
108
        $this->logger = $logger;
109
    }
110
}