Passed
Pull Request — master (#95)
by David
02:49
created

AlteredConfiguration::getSchemaAnalyzer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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