Passed
Push — 4.3 ( 28cdbc...a1e8cd )
by David
14:50 queued 13:41
created

AlteredConfiguration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
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 Mouf\Database\TDBM\Utils\PathFinder\PathFinderInterface;
13
use Psr\Log\LoggerInterface;
14
15
/**
16
 * A class to alter any ConfigurationInterface on the fly.
17
 *
18
 * The logger can be altered with setLogger method.
19
 * Useful to dynamically register a logger in the Symfony commands.
20
 */
21
class AlteredConfiguration implements ConfigurationInterface
22
{
23
    /**
24
     * @var ConfigurationInterface
25
     */
26
    private $configuration;
27
28
    /**
29
     * @var LoggerInterface
30
     */
31
    private $logger;
32
33
    public function __construct(ConfigurationInterface $configuration)
34
    {
35
        $this->configuration = $configuration;
36
        $this->logger = $configuration->getLogger();
37
    }
38
39
40
    /**
41
     * @return string
42
     */
43
    public function getBeanNamespace(): string
44
    {
45
        return $this->configuration->getBeanNamespace();
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getDaoNamespace(): string
52
    {
53
        return $this->configuration->getDaoNamespace();
54
    }
55
56
    /**
57
     * @return Connection
58
     */
59
    public function getConnection(): Connection
60
    {
61
        return $this->configuration->getConnection();
62
    }
63
64
    /**
65
     * @return Cache
66
     */
67
    public function getCache(): Cache
68
    {
69
        return $this->configuration->getCache();
70
    }
71
72
    /**
73
     * @return NamingStrategyInterface
74
     */
75
    public function getNamingStrategy(): NamingStrategyInterface
76
    {
77
        return $this->configuration->getNamingStrategy();
78
    }
79
80
    /**
81
     * @return SchemaAnalyzer
82
     */
83
    public function getSchemaAnalyzer(): SchemaAnalyzer
84
    {
85
        return $this->configuration->getSchemaAnalyzer();
86
    }
87
88
    /**
89
     * @return LoggerInterface
90
     */
91
    public function getLogger(): ?LoggerInterface
92
    {
93
        return $this->logger;
94
    }
95
96
    /**
97
     * @return GeneratorListenerInterface
98
     */
99
    public function getGeneratorEventDispatcher(): GeneratorListenerInterface
100
    {
101
        return $this->configuration->getGeneratorEventDispatcher();
102
    }
103
104
    /**
105
     * @param LoggerInterface $logger
106
     */
107
    public function setLogger(LoggerInterface $logger)
108
    {
109
        $this->logger = $logger;
110
    }
111
112
    /**
113
     * Returns a class able to find the place of a PHP file based on the class name.
114
     * Useful to find the path where DAOs and beans should be written to.
115
     *
116
     * @return PathFinderInterface
117
     */
118
    public function getPathFinder(): PathFinderInterface
119
    {
120
        return $this->configuration->getPathFinder();
121
    }
122
}
123