Completed
Pull Request — master (#14)
by Pavel
03:40
created

Configuration.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Bankiru\Api\Doctrine;
4
5
use Bankiru\Api\Doctrine\Cache\CacheConfiguration;
6
use Bankiru\Api\Doctrine\Cache\CacheConfigurationInterface;
7
use Bankiru\Api\Doctrine\Type\TypeRegistryInterface;
8
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
9
use Psr\Cache\CacheItemPoolInterface;
10
use Psr\Log\LoggerInterface;
11
use Psr\Log\NullLogger;
12
13
class Configuration
14
{
15
    /** @var  EntityMetadataFactory */
16
    private $metadataFactory;
17
    /** @var  MappingDriver */
18
    private $driver;
19
    /** @var  ClientRegistryInterface */
20
    private $clientRegistry;
21
    /** @var  ApiFactoryRegistryInterface */
22
    private $factoryRegistry;
23
    /** @var  string */
24
    private $proxyDir;
25
    /** @var  string */
26
    private $proxyNamespace;
27
    /** @var bool */
28
    private $autogenerateProxies = true;
29
    /** @var  TypeRegistryInterface */
30
    private $typeRegistry;
31
    /** @var  array */
32
    private $cacheConfiguration = [];
33
    /** @var  CacheItemPoolInterface */
34
    private $apiCache;
35
    /** @var  LoggerInterface */
36
    private $apiCacheLogger;
37
    /** @var  CacheConfigurationInterface[] */
38
    private $cacheConfigurationCache = [];
39
40
    /**
41
     * Configuration constructor.
42
     */
43 18
    public function __construct()
44
    {
45 18
        $this->apiCacheLogger = new NullLogger();
46 18
    }
47
48
    /**
49
     * @return ClientRegistryInterface
50
     */
51 18
    public function getClientRegistry()
52
    {
53 18
        return $this->clientRegistry;
54
    }
55
56
    /**
57
     * @param ClientRegistryInterface $clientRegistry
58
     */
59 18
    public function setClientRegistry($clientRegistry)
60
    {
61 18
        $this->clientRegistry = $clientRegistry;
62 18
    }
63
64
    /**
65
     * @return ApiFactoryRegistryInterface
66
     */
67 17
    public function getFactoryRegistry()
68
    {
69 17
        return $this->factoryRegistry;
70
    }
71
72
    /**
73
     * @param ApiFactoryRegistryInterface $factoryRegistry
74
     */
75 18
    public function setFactoryRegistry(ApiFactoryRegistryInterface $factoryRegistry)
76
    {
77 18
        $this->factoryRegistry = $factoryRegistry;
78 18
    }
79
80
    /**
81
     * @return LoggerInterface
82
     */
83 1
    public function getApiCacheLogger()
84
    {
85 1
        return $this->apiCacheLogger;
86
    }
87
88
    /**
89
     * @param LoggerInterface $apiCacheLogger
90
     */
91 1
    public function setApiCacheLogger($apiCacheLogger)
92
    {
93 1
        $this->apiCacheLogger = $apiCacheLogger;
94 1
    }
95
96
    /**
97
     * @return CacheItemPoolInterface
98
     */
99 1
    public function getApiCache()
100
    {
101 1
        return $this->apiCache;
102
    }
103
104
    /**
105
     * @param CacheItemPoolInterface|null $apiCache
106
     */
107 1
    public function setApiCache(CacheItemPoolInterface $apiCache = null)
108
    {
109 1
        $this->apiCache = $apiCache;
110 1
    }
111
112
    /**
113
     * Returns class cache configuration
114
     *
115
     * @param $class
116
     *
117
     * @return CacheConfigurationInterface
118
     */
119 17
    public function getCacheConfiguration($class)
120
    {
121 17
        if (!array_key_exists($class, $this->cacheConfiguration)) {
122 16
            return CacheConfiguration::disabled();
123
        }
124
125 1
        if (!array_key_exists($class, $this->cacheConfigurationCache)) {
126 1
            $this->cacheConfigurationCache[$class] = CacheConfiguration::create($this->cacheConfiguration[$class]);
127 1
        }
128
129 1
        return $this->cacheConfigurationCache[$class];
130
    }
131
132
    /**
133
     * @param string $class
134
     * @param array  $options
135
     */
136 1
    public function setCacheConfiguration($class, array $options = null)
137
    {
138 1
        $this->cacheConfiguration[$class] = $options;
139
140 1
        if (null === $this->cacheConfiguration[$class]) {
141
            unset($this->cacheConfiguration[$class]);
142
        }
143 1
    }
144
145
    /**
146
     * @return TypeRegistryInterface
147
     */
148 17
    public function getTypeRegistry()
149
    {
150 17
        return $this->typeRegistry;
151
    }
152
153
    /**
154
     * @param TypeRegistryInterface $typeRegistry
155
     */
156 18
    public function setTypeRegistry(TypeRegistryInterface $typeRegistry)
157
    {
158 18
        $this->typeRegistry = $typeRegistry;
159 18
    }
160
161
    /**
162
     * @return string
163
     */
164 18
    public function getProxyDir()
165
    {
166 18
        return $this->proxyDir;
167
    }
168
169
    /**
170
     * @param string $proxyDir
171
     */
172 18
    public function setProxyDir($proxyDir)
173
    {
174 18
        $this->proxyDir = $proxyDir;
175 18
    }
176
177
    /**
178
     * @return string
179
     */
180 18
    public function getProxyNamespace()
181
    {
182 18
        return $this->proxyNamespace;
183
    }
184
185
    /**
186
     * @param string $proxyNamespace
187
     */
188 18
    public function setProxyNamespace($proxyNamespace)
189
    {
190 18
        $this->proxyNamespace = $proxyNamespace;
191 18
    }
192
193
    /**
194
     * @return boolean
195
     */
196 18
    public function isAutogenerateProxies()
197
    {
198 18
        return $this->autogenerateProxies;
199
    }
200
201
    /**
202
     * @param boolean $autogenerateProxies
203
     */
204
    public function setAutogenerateProxies($autogenerateProxies)
205
    {
206
        $this->autogenerateProxies = $autogenerateProxies;
207
    }
208
209
    /**
210
     * @return MappingDriver
211
     */
212 18
    public function getDriver()
213
    {
214 18
        return $this->driver;
215
    }
216
217
    /**
218
     * @param MappingDriver $driver
219
     */
220 18
    public function setDriver($driver)
221
    {
222 18
        $this->driver = $driver;
223 18
    }
224
225
    /**
226
     * @return EntityMetadataFactory
227
     */
228 18
    public function getMetadataFactory()
229
    {
230 18
        return $this->metadataFactory;
231
    }
232
233
    /**
234
     * @param string $metadataFactory
235
     */
236 18
    public function setMetadataFactory($metadataFactory)
237
    {
238 18
        $this->metadataFactory = $metadataFactory;
0 ignored issues
show
Documentation Bug introduced by
It seems like $metadataFactory of type string is incompatible with the declared type object<Bankiru\Api\Doctr...\EntityMetadataFactory> of property $metadataFactory.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
239 18
    }
240
}
241