Completed
Push — dev ( bf86fc...9c27b7 )
by Андрей
04:28
created

ModuleOptions::setMetadataReaderCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\Doctrine\Options;
7
8
use Zend\Stdlib\AbstractOptions;
9
use Nnx\ModuleOptions\ModuleOptionsInterface;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Nnx\Doctrine\Options\ModuleOptionsInterface.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
10
use Nnx\Doctrine\Options\ModuleOptionsInterface as CurrentModuleOptionsInterface;
11
12
13
/**
14
 * Class ModuleOptions
15
 *
16
 * @package Nnx\Doctrine\Options
17
 */
18
class ModuleOptions extends AbstractOptions implements ModuleOptionsInterface, CurrentModuleOptionsInterface
19
{
20
    /**
21
     * Строка, используемая как разделитель в полном имени класса сущности(или интерфейса), которая разделяет неймспейс
22
     * на две части: 1) Нейсмпейс в котором расположенные все сущности 2) Постфикс указывающий на кокнетную сущность.
23
     * Например \Nnx\Doctrine\PhpUnit\TestData\EntityAutoResolve\TestModule1\Entity\TestEntity\TestEntityInterface
24
     * 1) Разделителем будет \Entity\
25
     * 2) Неймспейс в котром расположены все сущности будет \Nnx\Doctrine\PhpUnit\TestData\EntityAutoResolve\TestModule1\Entity\
26
     * 3) Постфикс указывающий на кокнетную сущность будет TestEntity\TestEntityInterface
27
     *
28
     * @var string
29
     */
30
    protected $entitySeparator;
31
32
    /**
33
     * Паттерн по которому из имени интерфейса можно получить строку, являющеюся заготовкой для формирования имени сущности
34
     *
35
     * @var string
36
     */
37
    protected $entityBodyNamePattern;
38
39
    /**
40
     * Строка которая добавляется перед  заготовкой имени сущности полученной в результате
41
     * примерения @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
42
     *
43
     * @var string
44
     */
45
    protected $entityNamePrefix;
46
47
    /**
48
     * Строка которая добавляется после заготовки имени сущности полученной в результате примерения
49
     * @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
50
     *
51
     * @var string
52
     */
53
    protected $entityNamePostfix;
54
55
    /**
56
     * Имя сервиса, позволяющего получить объект кеша из модуля doctrine/cache
57
     *
58
     * (@see https://github.com/doctrine/DoctrineModule)
59
     * (@see vendor/doctrine/doctrine-module/config/module.config.php)
60
     * (@see \DoctrineModule\Service\CacheFactory)
61
     *
62
     * @var string
63
     */
64
    protected $entityMapDoctrineCache;
65
66
    /**
67
     * Префикс используемы для генерации ключа кеширования карты сущностей doctrine
68
     *
69
     * @var string
70
     */
71
    protected $entityMapDoctrineCachePrefix;
72
73
    /**
74
     * Имя сервиса, позволяющего получить объект кеша из модуля doctrine/cache для кеширования метаданных сущности
75
     *
76
     * (@see https://github.com/doctrine/DoctrineModule)
77
     * (@see vendor/doctrine/doctrine-module/config/module.config.php)
78
     * (@see \DoctrineModule\Service\CacheFactory)
79
     *
80
     * @var string
81
     */
82
    protected $metadataReaderCache;
83
84
    /**
85
     * Строка, используемая как разделитель в полном имени класса сущности (@see \Nnx\Doctrine\Options\ModuleOptions::$entitySeparator)
86
     *
87
     * @return string
88
     */
89
    public function getEntitySeparator()
90
    {
91
        return $this->entitySeparator;
92
    }
93
94
    /**
95
     * Устанавливает строку используемую как разделитель в полном имени класса сущности (@see \Nnx\Doctrine\Options\ModuleOptions::$entitySeparator)
96
     *
97
     * @param string $entitySeparator
98
     *
99
     * @return $this
100
     */
101
    public function setEntitySeparator($entitySeparator)
102
    {
103
        $this->entitySeparator = $entitySeparator;
104
105
        return $this;
106
    }
107
108
    /**
109
     * @inheritdoc
110
     *
111
     * @return string
112
     */
113
    public function getEntityBodyNamePattern()
114
    {
115
        return $this->entityBodyNamePattern;
116
    }
117
118
    /**
119
     * Устанавливает паттерн по которому из имени интерфейса можно получить строку,
120
     * являющеюся заготовкой для формирования имени сущности
121
     *
122
     * @param string $entityBodyNamePattern
123
     *
124
     * @return $this
125
     */
126
    public function setEntityBodyNamePattern($entityBodyNamePattern)
127
    {
128
        $this->entityBodyNamePattern = $entityBodyNamePattern;
129
130
        return $this;
131
    }
132
133
    /**
134
     * @inheritdoc
135
     *
136
     * @return string
137
     */
138
    public function getEntityNamePrefix()
139
    {
140
        return $this->entityNamePrefix;
141
    }
142
143
    /**
144
     * Устанавливает строку которая добавляется перед  заготовкой именем сущности полученной в результате
145
     * примерения @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
146
     *
147
     * @param string $entityNamePrefix
148
     *
149
     * @return $this
150
     */
151
    public function setEntityNamePrefix($entityNamePrefix)
152
    {
153
        $this->entityNamePrefix = $entityNamePrefix;
154
155
        return $this;
156
    }
157
158
    /**
159
     * @inheritdoc
160
     *
161
     * @return string
162
     */
163
    public function getEntityNamePostfix()
164
    {
165
        return $this->entityNamePostfix;
166
    }
167
168
    /**
169
     * Устанавливает строку которая добавляется после заготовки имени сущности полученной в результате примерения
170
     * @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
171
     *
172
     * @param string $entityNamePostfix
173
     *
174
     * @return $this
175
     */
176
    public function setEntityNamePostfix($entityNamePostfix)
177
    {
178
        $this->entityNamePostfix = $entityNamePostfix;
179
180
        return $this;
181
    }
182
183
    /**
184
     * Возвращает имя сервиса, позволяющего получить объект кеша из модуля doctrine/cache
185
     *
186
     * @return string
187
     */
188
    public function getEntityMapDoctrineCache()
189
    {
190
        return $this->entityMapDoctrineCache;
191
    }
192
193
    /**
194
     * Устанавливает имя сервиса, позволяющего получить объект кеша из модуля doctrine/cache
195
     *
196
     * @param string $entityMapDoctrineCache
197
     *
198
     * @return $this
199
     */
200
    public function setEntityMapDoctrineCache($entityMapDoctrineCache)
201
    {
202
        $this->entityMapDoctrineCache = $entityMapDoctrineCache;
203
204
        return $this;
205
    }
206
207
    /**
208
     * Возвращает префикс используемы для генерации ключа кеширования карты сущностей doctrine
209
     *
210
     * @return string
211
     */
212
    public function getEntityMapDoctrineCachePrefix()
213
    {
214
        return $this->entityMapDoctrineCachePrefix;
215
    }
216
217
    /**
218
     * Возвращает префикс используемы для генерации ключа кеширования карты сущностей doctrine
219
     *
220
     * @param string $entityMapDoctrineCachePrefix
221
     *
222
     * @return $this
223
     */
224
    public function setEntityMapDoctrineCachePrefix($entityMapDoctrineCachePrefix)
225
    {
226
        $this->entityMapDoctrineCachePrefix = $entityMapDoctrineCachePrefix;
227
228
        return $this;
229
    }
230
231
    /**
232
     * @inheritdoc
233
     *
234
     * @return string
235
     */
236
    public function getMetadataReaderCache()
237
    {
238
        return $this->metadataReaderCache;
239
    }
240
241
    /**
242
     * Устанавливает имя сервиса, позволяющего получить объект кеша из модуля doctrine/cache для кеширования метаданных сущности
243
     *
244
     * @param string $metadataReaderCache
245
     *
246
     * @return $this
247
     */
248
    public function setMetadataReaderCache($metadataReaderCache)
249
    {
250
        $this->metadataReaderCache = $metadataReaderCache;
251
252
        return $this;
253
    }
254
}
255