Passed
Push — master ( 68f2b4...691f88 )
by Pavel
03:56 queued 21s
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 28
    public function __construct()
44
    {
45 28
        $this->apiCacheLogger = new NullLogger();
46 28
    }
47
48
    /**
49
     * @return ClientRegistryInterface
50
     */
51 27
    public function getClientRegistry()
52
    {
53 27
        return $this->clientRegistry;
54
    }
55
56
    /**
57
     * @param ClientRegistryInterface $clientRegistry
58
     */
59 28
    public function setClientRegistry($clientRegistry)
60
    {
61 28
        $this->clientRegistry = $clientRegistry;
62 28
    }
63
64
    /**
65
     * @return ApiFactoryRegistryInterface
66
     */
67 26
    public function getFactoryRegistry()
68
    {
69 26
        return $this->factoryRegistry;
70
    }
71
72
    /**
73
     * @param ApiFactoryRegistryInterface $factoryRegistry
74
     */
75 28
    public function setFactoryRegistry(ApiFactoryRegistryInterface $factoryRegistry)
76
    {
77 28
        $this->factoryRegistry = $factoryRegistry;
78 28
    }
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 27
    public function getCacheConfiguration($class)
120
    {
121 27
        if (!array_key_exists($class, $this->cacheConfiguration)) {
122 26
            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
     *
147
     *
148
     * @param string                      $class
149
     * @param CacheConfigurationInterface $configuration
150
     */
151
    public function setCacheConfigurationInstance($class, CacheConfigurationInterface $configuration)
152
    {
153
        $this->cacheConfigurationCache[$class] = $configuration;
154
    }
155
156
    /**
157
     * @return TypeRegistryInterface
158
     */
159 26
    public function getTypeRegistry()
160
    {
161 26
        return $this->typeRegistry;
162
    }
163
164
    /**
165
     * @param TypeRegistryInterface $typeRegistry
166
     */
167 28
    public function setTypeRegistry(TypeRegistryInterface $typeRegistry)
168
    {
169 28
        $this->typeRegistry = $typeRegistry;
170 28
    }
171
172
    /**
173
     * @return string
174
     */
175 28
    public function getProxyDir()
176
    {
177 28
        return $this->proxyDir;
178
    }
179
180
    /**
181
     * @param string $proxyDir
182
     */
183 28
    public function setProxyDir($proxyDir)
184
    {
185 28
        $this->proxyDir = $proxyDir;
186 28
    }
187
188
    /**
189
     * @return string
190
     */
191 28
    public function getProxyNamespace()
192
    {
193 28
        return $this->proxyNamespace;
194
    }
195
196
    /**
197
     * @param string $proxyNamespace
198
     */
199 28
    public function setProxyNamespace($proxyNamespace)
200
    {
201 28
        $this->proxyNamespace = $proxyNamespace;
202 28
    }
203
204
    /**
205
     * @return boolean
206
     */
207 28
    public function isAutogenerateProxies()
208
    {
209 28
        return $this->autogenerateProxies;
210
    }
211
212
    /**
213
     * @param boolean $autogenerateProxies
214
     */
215
    public function setAutogenerateProxies($autogenerateProxies)
216
    {
217
        $this->autogenerateProxies = $autogenerateProxies;
218
    }
219
220
    /**
221
     * @return MappingDriver
222
     */
223 28
    public function getDriver()
224
    {
225 28
        return $this->driver;
226
    }
227
228
    /**
229
     * @param MappingDriver $driver
230
     */
231 28
    public function setDriver($driver)
232
    {
233 28
        $this->driver = $driver;
234 28
    }
235
236
    /**
237
     * @return EntityMetadataFactory
238
     */
239 28
    public function getMetadataFactory()
240
    {
241 28
        return $this->metadataFactory;
242
    }
243
244
    /**
245
     * @param string $metadataFactory
246
     */
247 28
    public function setMetadataFactory($metadataFactory)
248
    {
249 28
        $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...
250 28
    }
251
}
252