Completed
Push — dev ( 526cfa...e5ce98 )
by Андрей
03:57
created

ModuleOptions::setEntityMapDoctrineCache()   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
     * Строка, используемая как разделитель в полном имени класса сущности (@see \Nnx\Doctrine\Options\ModuleOptions::$entitySeparator)
75
     *
76
     * @return string
77
     */
78
    public function getEntitySeparator()
79
    {
80
        return $this->entitySeparator;
81
    }
82
83
    /**
84
     * Устанавливает строку используемую как разделитель в полном имени класса сущности (@see \Nnx\Doctrine\Options\ModuleOptions::$entitySeparator)
85
     *
86
     * @param string $entitySeparator
87
     *
88
     * @return $this
89
     */
90
    public function setEntitySeparator($entitySeparator)
91
    {
92
        $this->entitySeparator = $entitySeparator;
93
94
        return $this;
95
    }
96
97
    /**
98
     * @inheritdoc
99
     *
100
     * @return string
101
     */
102
    public function getEntityBodyNamePattern()
103
    {
104
        return $this->entityBodyNamePattern;
105
    }
106
107
    /**
108
     * Устанавливает паттерн по которому из имени интерфейса можно получить строку,
109
     * являющеюся заготовкой для формирования имени сущности
110
     *
111
     * @param string $entityBodyNamePattern
112
     *
113
     * @return $this
114
     */
115
    public function setEntityBodyNamePattern($entityBodyNamePattern)
116
    {
117
        $this->entityBodyNamePattern = $entityBodyNamePattern;
118
119
        return $this;
120
    }
121
122
    /**
123
     * @inheritdoc
124
     *
125
     * @return string
126
     */
127
    public function getEntityNamePrefix()
128
    {
129
        return $this->entityNamePrefix;
130
    }
131
132
    /**
133
     * Устанавливает строку которая добавляется перед  заготовкой именем сущности полученной в результате
134
     * примерения @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
135
     *
136
     * @param string $entityNamePrefix
137
     *
138
     * @return $this
139
     */
140
    public function setEntityNamePrefix($entityNamePrefix)
141
    {
142
        $this->entityNamePrefix = $entityNamePrefix;
143
144
        return $this;
145
    }
146
147
    /**
148
     * @inheritdoc
149
     *
150
     * @return string
151
     */
152
    public function getEntityNamePostfix()
153
    {
154
        return $this->entityNamePostfix;
155
    }
156
157
    /**
158
     * Устанавливает строку которая добавляется после заготовки имени сущности полученной в результате примерения
159
     * @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
160
     *
161
     * @param string $entityNamePostfix
162
     *
163
     * @return $this
164
     */
165
    public function setEntityNamePostfix($entityNamePostfix)
166
    {
167
        $this->entityNamePostfix = $entityNamePostfix;
168
169
        return $this;
170
    }
171
172
    /**
173
     * Возвращает имя сервиса, позволяющего получить объект кеша из модуля doctrine/cache
174
     *
175
     * @return string
176
     */
177
    public function getEntityMapDoctrineCache()
178
    {
179
        return $this->entityMapDoctrineCache;
180
    }
181
182
    /**
183
     * Устанавливает имя сервиса, позволяющего получить объект кеша из модуля doctrine/cache
184
     *
185
     * @param string $entityMapDoctrineCache
186
     *
187
     * @return $this
188
     */
189
    public function setEntityMapDoctrineCache($entityMapDoctrineCache)
190
    {
191
        $this->entityMapDoctrineCache = $entityMapDoctrineCache;
192
193
        return $this;
194
    }
195
196
    /**
197
     * Возвращает префикс используемы для генерации ключа кеширования карты сущностей doctrine
198
     *
199
     * @return string
200
     */
201
    public function getEntityMapDoctrineCachePrefix()
202
    {
203
        return $this->entityMapDoctrineCachePrefix;
204
    }
205
206
    /**
207
     * Возвращает префикс используемы для генерации ключа кеширования карты сущностей doctrine
208
     *
209
     * @param string $entityMapDoctrineCachePrefix
210
     *
211
     * @return $this
212
     */
213
    public function setEntityMapDoctrineCachePrefix($entityMapDoctrineCachePrefix)
214
    {
215
        $this->entityMapDoctrineCachePrefix = $entityMapDoctrineCachePrefix;
216
217
        return $this;
218
    }
219
}
220